Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-08-31 22:44:15 +0300
committerGitHub <noreply@github.com>2020-08-31 22:44:15 +0300
commite7761b66117e7d1433402fd2d9b3d99d47317da6 (patch)
tree0eff6c03e494c9cc7155c1690574ab1871990636
parent59a61475d75c84ccf9f18dd9f69bae9d9e810e29 (diff)
parent0eeb1ea115e49f6a72bf2b56c9c45c9ed5b9287c (diff)
Merge pull request #22523 from nextcloud/backport/22514/stable17
[stable17] Fix S3 error handling
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 10c72dd3a00..291a283fe3f 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -441,7 +441,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$exists = $this->getCache()->inCache($path);
$uploadPath = $exists ? $path : $path . '.part';
- $fileId = $this->getCache()->put($uploadPath, $stat);
+
+ if ($exists) {
+ $fileId = $stat['fileid'];
+ } else {
+ $fileId = $this->getCache()->put($uploadPath, $stat);
+ }
+
$urn = $this->getURN($fileId);
try {
//upload to object storage
@@ -456,19 +462,33 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
if (is_resource($countStream)) {
fclose($countStream);
}
+ $stat['size'] = $size;
} else {
$this->objectStore->writeObject($urn, $stream);
}
} catch (\Exception $ex) {
- $this->getCache()->remove($uploadPath);
- $this->logger->logException($ex, [
- 'app' => 'objectstore',
- 'message' => 'Could not create object ' . $urn . ' for ' . $path,
- ]);
+ if (!$exists) {
+ /*
+ * Only remove the entry if we are dealing with a new file.
+ * Else people lose access to existing files
+ */
+ $this->getCache()->remove($uploadPath);
+ $this->logger->logException($ex, [
+ 'app' => 'objectstore',
+ 'message' => 'Could not create object ' . $urn . ' for ' . $path,
+ ]);
+ } else {
+ $this->logger->logException($ex, [
+ 'app' => 'objectstore',
+ 'message' => 'Could not update object ' . $urn . ' for ' . $path,
+ ]);
+ }
throw $ex; // make this bubble up
}
- if (!$exists) {
+ if ($exists) {
+ $this->getCache()->update($fileId, $stat);
+ } else {
if ($this->objectStore->objectExists($urn)) {
$this->getCache()->move($uploadPath, $path);
} else {