[Pkg-owncloud-commits] [owncloud] 44/457: dont go trough the view when moving to trash
David Prévot
taffit at moszumanska.debian.org
Sun Jun 28 20:05:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit b70e1ffc6d91a4ca2c6b66012ea6f7e5d39050a0
Author: Robin Appelman <icewind at owncloud.com>
Date: Wed May 13 14:09:07 2015 +0200
dont go trough the view when moving to trash
---
apps/files_trashbin/lib/trashbin.php | 39 +++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 31d77c0..9c8aa5e 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);
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list