diff options
author | Joas Schilling <coding@schilljs.com> | 2018-02-28 15:40:01 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-03-06 12:16:04 +0100 |
commit | 8f8d7cf9d36c139ea39572b68ce345d1696c19b6 (patch) | |
tree | 6f2ac7bb5166d287150f08006b3b9c1330d46aa4 | |
parent | 5d8aaf9696af82a69ab36b5388f1114ccdf3a2ce (diff) | |
download | nextcloud-server-8f8d7cf9d36c139ea39572b68ce345d1696c19b6.tar.gz nextcloud-server-8f8d7cf9d36c139ea39572b68ce345d1696c19b6.zip |
Catch exception when the parent is deleted as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/files/lib/Activity/Provider.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index 8c17f402fad..e868e1c464a 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -395,8 +395,13 @@ class Provider implements IProvider { $userFolder = $this->rootFolder->getUserFolder($this->activityManager->getCurrentUserId()); $files = $userFolder->getById($fileId); if (empty($files)) { - // Deleted, try with parent - $file = $userFolder->get(dirname($path)); + try { + // Deleted, try with parent + $file = $this->findExistingParent($userFolder, dirname($path)); + } catch (NotFoundException $e) { + return null; + } + if (!$file instanceof Folder || !$file->isEncrypted()) { return null; } @@ -419,6 +424,26 @@ class Provider implements IProvider { } /** + * @param Folder $userFolder + * @param string $path + * @return Folder + * @throws NotFoundException + */ + protected function findExistingParent(Folder $userFolder, $path) { + if ($path === '/') { + throw new NotFoundException('Reached the root'); + } + + try { + $folder = $userFolder->get(dirname($path)); + } catch (NotFoundException $e) { + return $this->findExistingParent($userFolder, dirname($path)); + } + + return $folder; + } + + /** * Check all parents until the user's root folder if one is encrypted * * @param Folder $userFolder |