diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-05-13 14:09:07 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-05-18 17:16:12 +0200 |
commit | b70e1ffc6d91a4ca2c6b66012ea6f7e5d39050a0 (patch) | |
tree | 0230721b1c2b69c4aa1fb3086afea9ba77325306 /apps/files_trashbin/lib | |
parent | b085f5855362bb8c305083c1d60ebfd459323a96 (diff) | |
download | nextcloud-server-b70e1ffc6d91a4ca2c6b66012ea6f7e5d39050a0.tar.gz nextcloud-server-b70e1ffc6d91a4ca2c6b66012ea6f7e5d39050a0.zip |
dont go trough the view when moving to trash
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 31d77c01c91..9c8aa5e7525 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -184,22 +184,27 @@ class Trashbin { // disable proxy to prevent recursive calls $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; + + /** @var \OC\Files\Storage\Storage $trashStorage */ + list($trashStorage, $trashInternalPath) = $view->resolvePath($trashPath); + /** @var \OC\Files\Storage\Storage $sourceStorage */ + list($sourceStorage, $sourceInternalPath) = $view->resolvePath('/files/' . $file_path); try { - $sizeOfAddedFiles = $view->filesize('/files/' . $file_path); - if ($view->file_exists($trashPath)) { - $view->unlink($trashPath); + $sizeOfAddedFiles = $sourceStorage->filesize($sourceInternalPath); + if ($trashStorage->file_exists($trashInternalPath)) { + $trashStorage->unlink($trashInternalPath); } - $view->rename('/files/' . $file_path, $trashPath); + $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) { $sizeOfAddedFiles = false; - if ($view->file_exists($trashPath)) { - $view->deleteAll($trashPath); + if ($trashStorage->file_exists($trashInternalPath)) { + $trashStorage->unlink($trashInternalPath); } \OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR); } - if ($view->file_exists('/files/' . $file_path)) { // failed to delete the original file, abort - $view->unlink($trashPath); + if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort + $sourceStorage->unlink($sourceInternalPath); return false; } @@ -257,18 +262,28 @@ class Trashbin { } if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { + /** @var \OC\Files\Storage\Storage $versionStorage */ + list($versionStorage, $versionsInternalPath) = $rootView->resolvePath($owner . '/files_versions/' . $ownerPath); + /** @var \OC\Files\Storage\Storage $trashStorage */ + list($trashStorage, $trashInternalPath) = $rootView->resolvePath($user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); + $size += self::calculateSize(new \OC\Files\View('/' . $owner . '/files_versions/' . $ownerPath)); if ($owner !== $user) { self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView); } - $rootView->rename($owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp); + $trashStorage->moveFromStorage($versionStorage, $versionsInternalPath, $trashInternalPath); } else if ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) { + /** @var \OC\Files\Storage\Storage $versionStorage */ + list($versionStorage, $versionsInternalPath) = $rootView->resolvePath($owner . '/files_versions/'); + /** @var \OC\Files\Storage\Storage $trashStorage */ + list($trashStorage, $trashInternalPath) = $rootView->resolvePath($user . '/files_trashbin/versions/'); + foreach ($versions as $v) { - $size += $rootView->filesize($owner . '/files_versions' . $v['path'] . '.v' . $v['version']); + $size += $versionStorage->filesize($versionsInternalPath . $v['path'] . '.v' . $v['version']); if ($owner !== $user) { - $rootView->copy($owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp); + $trashStorage->copyFromStorage($versionStorage, $versionsInternalPath . $v['path'] . '.v' . $v['version'], $owner . $trashInternalPath . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp); } - $rootView->rename($owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp); + $trashStorage->moveFromStorage($versionStorage, $versionsInternalPath . $v['path'] . '.v' . $v['version'], $trashInternalPath . $filename . '.v' . $v['version'] . '.d' . $timestamp); } } } |