From e360885eb0562821c7dc69e988d4aa86418e68cf Mon Sep 17 00:00:00 2001 From: Lars Knickrehm Date: Mon, 28 May 2018 00:59:20 +0200 Subject: Workaround for interrupting expired files deletion Workaround avoiding "Error while running background job (class: OCA\Files_Trashbin\BackgroundJob\ExpireTrash, arguments: ): {"Exception":"OCP\\Files\\NotPermittedException","Message":"","Code":0,"Trace":"#0 \/var\/www\/cloud\/apps\/files_trashbin\/lib\/Trashbin.php(590): OC\\Files\\Node\\File->delete() [...]" --- apps/files_trashbin/lib/Trashbin.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index bf396d40abf..eb1a6f704fd 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -790,8 +790,15 @@ class Trashbin { $timestamp = $file['mtime']; $filename = $file['name']; if ($expiration->isExpired($timestamp)) { - $count++; - $size += self::delete($filename, $user, $timestamp); + try { + $size += self::delete($filename, $user, $timestamp); + $count++; + } catch (\OCP\Files\NotPermittedException $e) { + \OC::$server->getLogger()->warning( + 'Removing "' . $filename . '" from trashbin failed (OCP\\Files\\NotPermittedException).', + ['app' => 'files_trashbin'] + ); + } \OC::$server->getLogger()->info( 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', ['app' => 'files_trashbin'] -- cgit v1.2.3 From 436c4f895480b73190861e98669301ebd95cdc8c Mon Sep 17 00:00:00 2001 From: Lars Knickrehm Date: Sun, 24 Jun 2018 13:41:16 +0200 Subject: Improved logging statement --- apps/files_trashbin/lib/Trashbin.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index eb1a6f704fd..b9a8a42a21c 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -794,10 +794,7 @@ class Trashbin { $size += self::delete($filename, $user, $timestamp); $count++; } catch (\OCP\Files\NotPermittedException $e) { - \OC::$server->getLogger()->warning( - 'Removing "' . $filename . '" from trashbin failed (OCP\\Files\\NotPermittedException).', - ['app' => 'files_trashbin'] - ); + \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']); } \OC::$server->getLogger()->info( 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', -- cgit v1.2.3