mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 11:11:42 -04:00
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>
This commit is contained in:
parent
e2219b8e4d
commit
0eeb1ea115
1 changed files with 11 additions and 2 deletions
|
|
@ -441,7 +441,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
|
||||
|
|
@ -456,6 +462,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
|||
if (is_resource($countStream)) {
|
||||
fclose($countStream);
|
||||
}
|
||||
$stat['size'] = $size;
|
||||
} else {
|
||||
$this->objectStore->writeObject($urn, $stream);
|
||||
}
|
||||
|
|
@ -479,7 +486,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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue