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
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-08-31 13:28:04 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-08-31 20:08:35 +0300
commit55ce30ad53ce1998fee06a75b02351fea53c7c96 (patch)
tree733f9fa80d43296f95dbb4c59c8a49ae2ca3015d /lib
parentf909d2a39ad8c400a1e8bdef34dc3fd8b2ec6bd9 (diff)
Only update the filecache entry once the file has been written to S3
If we already update before we have no way to revert if the upload fails. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 1658c913910..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,6 +465,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
if (is_resource($countStream)) {
fclose($countStream);
}
+ $stat['size'] = $size;
} else {
$this->objectStore->writeObject($urn, $stream);
}
@@ -482,7 +489,9 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
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 {