aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php')
-rw-r--r--apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
index c587d463501..bb383dab78d 100644
--- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
+++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -14,12 +15,14 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IAppConfig;
use OCP\IUserManager;
+use Psr\Log\LoggerInterface;
class ExpireTrash extends TimedJob {
public function __construct(
private IAppConfig $appConfig,
private IUserManager $userManager,
private Expiration $expiration,
+ private LoggerInterface $logger,
ITimeFactory $time,
) {
parent::__construct($time);
@@ -43,12 +46,16 @@ class ExpireTrash extends TimedJob {
$users = $this->userManager->getSeenUsers($offset);
foreach ($users as $user) {
- $uid = $user->getUID();
- if (!$this->setupFS($uid)) {
- continue;
+ try {
+ $uid = $user->getUID();
+ if (!$this->setupFS($uid)) {
+ continue;
+ }
+ $dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
+ Trashbin::deleteExpiredFiles($dirContent, $uid);
+ } catch (\Throwable $e) {
+ $this->logger->error('Error while expiring trashbin for user ' . $user->getUID(), ['exception' => $e]);
}
- $dirContent = Helper::getTrashFiles('/', $uid, 'mtime');
- Trashbin::deleteExpiredFiles($dirContent, $uid);
$offset++;