aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Command
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2025-04-02 12:45:00 +0200
committerLouis Chemineau <louis@chmn.me>2025-04-02 17:04:06 +0200
commit0a585b004855d5906dbd8dac17d03b4a64fcefc7 (patch)
tree1ca7f8d40dcda5fbfb1a4b6bf0d979a874a49296 /apps/files_trashbin/lib/Command
parent9677cb86cb37e474a5072cad21341ab6ea45794e (diff)
downloadnextcloud-server-0a585b004855d5906dbd8dac17d03b4a64fcefc7.tar.gz
nextcloud-server-0a585b004855d5906dbd8dac17d03b4a64fcefc7.zip
fix: Catch exceptions when expiring trashbinartonge/fix/catch_exception_in_expire_trash
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_trashbin/lib/Command')
-rw-r--r--apps/files_trashbin/lib/Command/ExpireTrash.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php
index 2dd02807cfd..de1c2ab09b4 100644
--- a/apps/files_trashbin/lib/Command/ExpireTrash.php
+++ b/apps/files_trashbin/lib/Command/ExpireTrash.php
@@ -12,6 +12,7 @@ use OCA\Files_Trashbin\Helper;
use OCA\Files_Trashbin\Trashbin;
use OCP\IUser;
use OCP\IUserManager;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
@@ -25,6 +26,7 @@ class ExpireTrash extends Command {
* @param Expiration|null $expiration
*/
public function __construct(
+ private LoggerInterface $logger,
private ?IUserManager $userManager = null,
private ?Expiration $expiration = null,
) {
@@ -77,12 +79,16 @@ class ExpireTrash extends Command {
}
public function expireTrashForUser(IUser $user) {
- $uid = $user->getUID();
- if (!$this->setupFS($uid)) {
- return;
+ try {
+ $uid = $user->getUID();
+ if (!$this->setupFS($uid)) {
+ return;
+ }
+ $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);
}
/**