summaryrefslogtreecommitdiffstats
path: root/lib/private/connector
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-21 13:21:39 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-21 13:21:39 +0200
commit3cb666ad7732cd2bff5cc172e40d1b22407aa640 (patch)
tree7bf17409e09149519e3134ba3fefc91625eddd8a /lib/private/connector
parentf5a6d6b43e6a91d0e9ef0940e1a83530f5a5cff6 (diff)
downloadnextcloud-server-3cb666ad7732cd2bff5cc172e40d1b22407aa640.tar.gz
nextcloud-server-3cb666ad7732cd2bff5cc172e40d1b22407aa640.zip
chunked files are assembled into a part file on the target storage followed by an atomic rename operation.
Diffstat (limited to 'lib/private/connector')
-rw-r--r--lib/private/connector/sabre/file.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 3402946a136..85b67e65871 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -223,9 +223,22 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
if ($chunk_handler->isComplete()) {
- $newPath = $path . '/' . $info['name'];
- $chunk_handler->file_assemble($newPath);
- return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
+
+ // we first assembly the target file as a part file
+ $partFile = $path . '/' . $info['name'] . '-' . $info['transferid'] . '.part';
+ $chunk_handler->file_assemble($partFile);
+
+ // here is the final atomic rename
+ $fs = $this->getFS();
+ $targetPath = $path . '/' . $info['name'];
+ $renameOkay = $fs->rename($partFile, $targetPath);
+ $fileExists = $fs->file_exists($targetPath);
+ if ($renameOkay === false || $fileExists === false) {
+ \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
+ $fs->unlink($targetPath);
+ throw new Sabre_DAV_Exception();
+ }
+ return OC_Connector_Sabre_Node::getETagPropertyForPath($targetPath);
}
return null;