diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-08-31 21:44:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 21:44:11 +0200 |
commit | 3fbf45bb32fba252a30f952eaa261ced953ac032 (patch) | |
tree | 733f9fa80d43296f95dbb4c59c8a49ae2ca3015d | |
parent | db36ad575a205d2fccad168cab752db6280c0c0b (diff) | |
parent | 55ce30ad53ce1998fee06a75b02351fea53c7c96 (diff) | |
download | nextcloud-server-3fbf45bb32fba252a30f952eaa261ced953ac032.tar.gz nextcloud-server-3fbf45bb32fba252a30f952eaa261ced953ac032.zip |
Merge pull request #22522 from nextcloud/backport/22514/stable18
[stable18] Fix S3 error handling
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index e0d437839a0..bd5b2d47770 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -444,7 +444,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 @@ -459,19 +465,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 { |