summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-05 11:49:31 +0100
committerRobin Appelman <icewind@owncloud.com>2015-04-13 15:13:03 +0200
commit0772e3b4c11a387dfcd774caf1018d73106cd064 (patch)
treeaf9d8ea86950385b36b380f9cd370831084d78d8 /lib/private
parent404773940daf9c5a686b92d65dd39fb44d766050 (diff)
downloadnextcloud-server-0772e3b4c11a387dfcd774caf1018d73106cd064.tar.gz
nextcloud-server-0772e3b4c11a387dfcd774caf1018d73106cd064.zip
Properly handle copy/move failures in cross storage copy/move
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/storage/common.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index ca898bcc0b3..66ed713e22d 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -537,7 +537,7 @@ abstract class Common implements Storage {
$dh = $sourceStorage->opendir($sourceInternalPath);
$result = $this->mkdir($targetInternalPath);
if (is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
+ while ($result and ($file = readdir($dh)) !== false) {
if (!Filesystem::isIgnoredDir($file)) {
$result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file);
}
@@ -547,13 +547,20 @@ abstract class Common implements Storage {
$source = $sourceStorage->fopen($sourceInternalPath, 'r');
$target = $this->fopen($targetInternalPath, 'w');
list(, $result) = \OC_Helper::streamCopy($source, $target);
- if ($preserveMtime) {
+ if ($result and $preserveMtime) {
$this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
}
fclose($source);
fclose($target);
+
+ if (!$result) {
+ // delete partially written target file
+ $this->unlink($targetInternalPath);
+ // delete cache entry that was created by fopen
+ $this->getCache()->remove($targetInternalPath);
+ }
}
- return $result;
+ return (bool)$result;
}
/**