aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-08-31 12:28:04 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-08-31 17:08:27 +0000
commit952ec3370e2f096f9489863edc8c48842e3fd8af (patch)
tree7a6043f8fde639fae4b4d72d4b8c7733dda83f46 /lib/private
parent704f515175c0001ae11a949571445eacf4962242 (diff)
downloadnextcloud-server-952ec3370e2f096f9489863edc8c48842e3fd8af.tar.gz
nextcloud-server-952ec3370e2f096f9489863edc8c48842e3fd8af.zip
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/private')
-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 b2ec094a71e..faa0342935e 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -446,7 +446,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
@@ -461,6 +467,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
if (is_resource($countStream)) {
fclose($countStream);
}
+ $stat['size'] = $size;
} else {
$this->objectStore->writeObject($urn, $stream);
}
@@ -484,7 +491,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 {