aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/ObjectStore/ObjectStoreStorage.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-08-31 12:28:04 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2020-08-31 12:28:04 +0200
commit789b33aba498dddb7c73a9966da75c82008d42de (patch)
tree75d3303dfbac95db461722bb0897c64dc8ef80fa /lib/private/Files/ObjectStore/ObjectStoreStorage.php
parent6ffd7173f909788dd1808e493b94ec390a785604 (diff)
downloadnextcloud-server-789b33aba498dddb7c73a9966da75c82008d42de.tar.gz
nextcloud-server-789b33aba498dddb7c73a9966da75c82008d42de.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/Files/ObjectStore/ObjectStoreStorage.php')
-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 {