]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't lose filecache entry on s3 overwrite error
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 31 Aug 2020 10:25:20 +0000 (12:25 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Mon, 31 Aug 2020 10:25:20 +0000 (12:25 +0200)
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>
lib/private/Files/ObjectStore/ObjectStoreStorage.php

index a5112bcbba6864b49236aca5944d9e4525a2f8fd..b2ec094a71e14e388d35798255356b44a1f6b3d7 100644 (file)
@@ -465,11 +465,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
                }