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 /apps | |
parent | 2e8c70327a7d3780ee5887b172159dc0f4c76c44 (diff) | |
download | nextcloud-server-87a1b2bdc41b6a54665ded5b5ffdb9b57325177d.tar.gz nextcloud-server-87a1b2bdc41b6a54665ded5b5ffdb9b57325177d.zip |
Preserve mtime when doing cross storage move
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 1833936ea26..f5cebea6b78 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -166,7 +166,8 @@ class Trashbin { \OC_FileProxy::$enabled = false; $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; try { - $sizeOfAddedFiles = self::renameRecursive('/files/'.$file_path, $trashPath, $view); + $sizeOfAddedFiles = $view->filesize('/files/' . $file_path); + $view->rename('/files/' . $file_path, $trashPath); } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) { $sizeOfAddedFiles = false; if ($view->file_exists($trashPath)) { @@ -806,46 +807,6 @@ class Trashbin { } /** - * recursive rename a whole directory and preserve timestamps - * - * @param string $source source path, relative to the users files directory - * @param string $destination destination path relative to the users root directoy - * @param \OC\Files\View $view file view for the users root directory - * @return int - * @throws Exceptions\CopyRecursiveException - */ - private static function renameRecursive($source, $destination, \OC\Files\View $view) { - $size = 0; - if ($view->is_dir($source)) { - $view->mkdir($destination); - $view->touch($destination, $view->filemtime($source)); - foreach ($view->getDirectoryContent($source) as $i) { - $pathDir = $source . '/' . $i['name']; - if ($view->is_dir($pathDir)) { - $size += self::renameRecursive($pathDir, $destination . '/' . $i['name'], $view); - } else { - $size += $view->filesize($pathDir); - $mtime = $view->filemtime($pathDir); - $result = $view->rename($pathDir, $destination . '/' . $i['name']); - if (!$result) { - throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException(); - } - $view->touch($destination . '/' . $i['name'], $mtime); - } - } - } else { - $size += $view->filesize($source); - $mtime = $view->filemtime($source); - $result = $view->rename($source, $destination); - if (!$result) { - throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException(); - } - $view->touch($destination, $mtime); - } - return $size; - } - - /** * find all versions which belong to the file we want to restore * * @param string $filename name of the file which should be restored |