diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-01-23 15:11:27 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-01-23 15:11:27 +0100 |
commit | 87a1b2bdc41b6a54665ded5b5ffdb9b57325177d (patch) | |
tree | 3d2dee78c8d8f58acf5c1f4c4ff3b66aab347f37 /lib/private/files | |
parent | 2e8c70327a7d3780ee5887b172159dc0f4c76c44 (diff) | |
download | nextcloud-server-87a1b2bdc41b6a54665ded5b5ffdb9b57325177d.tar.gz nextcloud-server-87a1b2bdc41b6a54665ded5b5ffdb9b57325177d.zip |
Preserve mtime when doing cross storage move
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/view.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 76b7d34e756..f466361bd02 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -511,7 +511,7 @@ class View { } } else { if ($this->is_dir($path1)) { - $result = $this->copy($path1, $path2); + $result = $this->copy($path1, $path2, true); if ($result === true) { $result = $storage1->rmdir($internalPath1); } @@ -519,6 +519,7 @@ class View { $source = $this->fopen($path1 . $postFix1, 'r'); $target = $this->fopen($path2 . $postFix2, 'w'); list($count, $result) = \OC_Helper::streamCopy($source, $target); + $this->touch($path2, $this->filemtime($path1)); // close open handle - especially $source is necessary because unlink below will // throw an exception on windows because the file is locked @@ -556,7 +557,7 @@ class View { } } - public function copy($path1, $path2) { + public function copy($path1, $path2, $preserveMtime = false) { $postFix1 = (substr($path1, -1, 1) === '/') ? '/' : ''; $postFix2 = (substr($path2, -1, 1) === '/') ? '/' : ''; $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); @@ -601,10 +602,13 @@ class View { } else { if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) { $result = $this->mkdir($path2); + if ($preserveMtime) { + $this->touch($path2, $this->filemtime($path1)); + } if (is_resource($dh)) { while (($file = readdir($dh)) !== false) { if (!Filesystem::isIgnoredDir($file)) { - $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file); + $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file, $preserveMtime); } } } @@ -612,6 +616,9 @@ class View { $source = $this->fopen($path1 . $postFix1, 'r'); $target = $this->fopen($path2 . $postFix2, 'w'); list($count, $result) = \OC_Helper::streamCopy($source, $target); + if($preserveMtime) { + $this->touch($path2, $this->filemtime($path1)); + } fclose($source); fclose($target); } |