Catch exception when the parent is deleted as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
825c276e84
commit
0b883ab9d9
|
@ -395,8 +395,13 @@ class Provider implements IProvider {
|
|||
$userFolder = $this->rootFolder->getUserFolder($this->activityManager->getCurrentUserId());
|
||||
$files = $userFolder->getById($fileId);
|
||||
if (empty($files)) {
|
||||
try {
|
||||
// Deleted, try with parent
|
||||
$file = $userFolder->get(dirname($path));
|
||||
$file = $this->findExistingParent($userFolder, dirname($path));
|
||||
} catch (NotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$file instanceof Folder || !$file->isEncrypted()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -418,6 +423,26 @@ class Provider implements IProvider {
|
|||
return $this->fileEncrypted[$fileId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue