summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-02-28 15:40:01 +0100
committerJoas Schilling <coding@schilljs.com>2018-02-28 15:40:01 +0100
commit0b883ab9d940650582e8ee02ada5bf13c2be7915 (patch)
tree8b7162eadb69c4dbf869e051dfa93368fcf7aaeb /apps/files/lib
parent825c276e84821b2520390a85136a7e17fcd2be9b (diff)
downloadnextcloud-server-0b883ab9d940650582e8ee02ada5bf13c2be7915.tar.gz
nextcloud-server-0b883ab9d940650582e8ee02ada5bf13c2be7915.zip
Catch exception when the parent is deleted as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/Activity/Provider.php29
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