aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-12-21 17:43:14 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2016-12-21 18:02:19 +0100
commita1d6f3068a2d34ac9597af7a9bfff74eb577b4fc (patch)
treec9c9b3dcc4923a90f38209fa89ba46c63e1f6eb7 /apps
parent60810b44bc28b3ce6fcd3c6e393ed647c105f25e (diff)
downloadnextcloud-server-a1d6f3068a2d34ac9597af7a9bfff74eb577b4fc.tar.gz
nextcloud-server-a1d6f3068a2d34ac9597af7a9bfff74eb577b4fc.zip
make code more robust
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/Storage.php35
1 files changed, 25 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php
index 8dd41924aa6..b8f154ea051 100644
--- a/apps/files_trashbin/lib/Storage.php
+++ b/apps/files_trashbin/lib/Storage.php
@@ -44,6 +44,12 @@ class Storage extends Wrapper {
*/
private static $disableTrash = false;
+ /**
+ * remember which file/folder was moved out of s shared folder
+ * in this case we want to add a copy to the owners trash bin
+ *
+ * @var array
+ */
private static $moveOutOfSharedFolder = [];
/** @var IUserManager */
@@ -77,19 +83,28 @@ class Storage extends Wrapper {
$fileMovedOutOfSharedFolder = false;
- if ($currentUser) {
- $currentUserId = $currentUser->getUID();
+ try {
+ if ($currentUser) {
+ $currentUserId = $currentUser->getUID();
- $view = new View($currentUserId . '/files');
- $sourceStorage = $view->getFileInfo($oldPath)->getStorage();
- $sourceOwner = $view->getOwner($oldPath);
- $targetOwner = $view->getOwner($newPath);
+ $view = new View($currentUserId . '/files');
+ $fileInfo = $view->getFileInfo($oldPath);
+ if ($fileInfo) {
+ $sourceStorage = $fileInfo->getStorage();
+ $sourceOwner = $view->getOwner($oldPath);
+ $targetOwner = $view->getOwner($newPath);
- if($sourceOwner !== $targetOwner
- && $sourceStorage->instanceOfStorage('OCA\Files_Sharing\SharedStorage')
- ) {
- $fileMovedOutOfSharedFolder = true;
+ if ($sourceOwner !== $targetOwner
+ && $sourceStorage->instanceOfStorage('OCA\Files_Sharing\SharedStorage')
+ ) {
+ $fileMovedOutOfSharedFolder = true;
+ }
+ }
}
+ } catch (\Exception $e) {
+ // do nothing, in this case we just disable the trashbin and continue
+ $logger = \OC::$server->getLogger();
+ $logger->debug('Trashbin storage could not check if a file was moved out of a shared folder: ' . $e->getMessage());
}
if($fileMovedOutOfSharedFolder) {