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

github.com/nextcloud/files_retention.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/BackgroundJob/RetentionJob.php')
-rw-r--r--lib/BackgroundJob/RetentionJob.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/BackgroundJob/RetentionJob.php b/lib/BackgroundJob/RetentionJob.php
index 7a894cf..2d1215e 100644
--- a/lib/BackgroundJob/RetentionJob.php
+++ b/lib/BackgroundJob/RetentionJob.php
@@ -31,7 +31,9 @@ use OCA\Files_Retention\AppInfo\Application;
use OCA\Files_Retention\Constants;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
+use OCP\Files\Config\ICachedMountFileInfo;
use OCP\Files\Config\IUserMountCache;
+use OCP\Files\NotPermittedException;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Files\Node;
@@ -195,8 +197,21 @@ class RetentionJob extends TimedJob {
throw new NotFoundException("No mount points found for file $fileId");
}
- $mountPoint = array_shift($mountPoints);
+ foreach ($mountPoints as $mountPoint) {
+ try {
+ return $this->getDeletableNodeFromMountPoint($mountPoint, $fileId);
+ } catch (NotPermittedException $e) {
+ // Check the next mount point
+ $this->logger->debug('Mount point ' . ($mountPoint->getMountId() ?? 'null') . ' has no delete permissions for file ' . $fileId);
+ } catch (NotFoundException $e) {
+ // Already logged explicitly inside
+ }
+ }
+
+ throw new NotFoundException("No mount point with delete permissions found for file $fileId");
+ }
+ protected function getDeletableNodeFromMountPoint(ICachedMountFileInfo $mountPoint, int $fileId): Node {
try {
$userId = $mountPoint->getUser()->getUID();
$userFolder = $this->rootFolder->getUserFolder($userId);
@@ -217,7 +232,14 @@ class RetentionJob extends TimedJob {
throw new NotFoundException('No node for file ' . $fileId . ' and user ' . $userId);
}
- return array_shift($nodes);
+ foreach ($nodes as $node) {
+ if ($node->isDeletable()) {
+ return $node;
+ }
+ $this->logger->debug('Mount point ' . ($mountPoint->getMountId() ?? 'null') . ' has access to node ' . $node->getId() . ' but permissions are ' . $node->getPermissions());
+ }
+
+ throw new NotPermittedException();
}
private function expireNode(Node $node, \DateTime $deleteBefore): bool {