diff options
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/storage/common.php | 13 |
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; } /** |