diff options
author | Joas Schilling <coding@schilljs.com> | 2018-02-12 16:25:36 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-02-28 15:06:06 +0100 |
commit | 62e982a91f2ca021171b84affd9d7867eb41e387 (patch) | |
tree | 1d09cf21e734463c1e564f976335f7f51568fc97 | |
parent | d202bae3b592f7d525d28e0b7753d8f642c20431 (diff) | |
download | nextcloud-server-62e982a91f2ca021171b84affd9d7867eb41e387.tar.gz nextcloud-server-62e982a91f2ca021171b84affd9d7867eb41e387.zip |
Fix problem with deleted files
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/files/lib/Activity/Provider.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index 83f5dbaf787..fb72d93c248 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -340,7 +340,7 @@ class Provider implements IProvider { throw new \InvalidArgumentException('Could not generate file parameter'); } - $encryptionContainer = $this->getEndToEndEncryptionContainer($id, basename($path)); + $encryptionContainer = $this->getEndToEndEncryptionContainer($id, $path); if ($encryptionContainer instanceof Folder) { $this->fileIsEncrypted = true; try { @@ -378,14 +378,15 @@ class Provider implements IProvider { /** * Check if a file is end2end encrypted * @param int $fileId - * @param string $fileName - * @return bool + * @param string $path + * @return Folder|null */ - protected function getEndToEndEncryptionContainer($fileId, $fileName) { + protected function getEndToEndEncryptionContainer($fileId, $path) { if (isset($this->fileEncrypted[$fileId])) { return $this->fileEncrypted[$fileId]; } + $fileName = basename($path); if (!preg_match('/^[0-9a-fA-F]{32}$/', $fileName)) { $this->fileEncrypted[$fileId] = false; return $this->fileEncrypted[$fileId]; @@ -394,10 +395,18 @@ class Provider implements IProvider { $userFolder = $this->rootFolder->getUserFolder($this->activityManager->getCurrentUserId()); $files = $userFolder->getById($fileId); if (empty($files)) { - return null; + // Deleted, try with parent + $file = $userFolder->get(dirname($path)); + if (!$file instanceof Folder || !$file->isEncrypted()) { + return null; + } + + $this->fileEncrypted[$fileId] = $file; + return $file; } $file = array_shift($files); + if ($file instanceof Folder && $file->isEncrypted()) { // If the folder is encrypted, it is the Container, // but can be the name is just fine. |