Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-02-12 18:25:36 +0300
committerJoas Schilling <coding@schilljs.com>2018-03-06 14:15:51 +0300
commit7c15b99a493b14fec22d6b5c311135499727dedb (patch)
tree4f4cf0a58699475b53cc9980cf4fc2a66dc75fc7 /apps
parentf1e01dbbbc64d4d8b5d84d4979ef80f505376b31 (diff)
Fix problem with deleted files
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Activity/Provider.php19
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.