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 <roeland@famdouma.nl>2020-08-31 13:25:20 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-08-31 20:08:41 +0300
commite2219b8e4d7d7dacd612a90c4df5b2fcfcb2f0d8 (patch)
treefbd48849e4ac174c2711ca70101643bf3068d4f1
parent59a61475d75c84ccf9f18dd9f69bae9d9e810e29 (diff)
Don't lose filecache entry on s3 overwrite error
If the object store errors we should not always delete the filecache entry. As this might lead to people losing access to their files. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 10c72dd3a00..2dcc5e74967 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -460,11 +460,22 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$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
}