From 9e1304bd51e9395786afe97f2803089966abe800 Mon Sep 17 00:00:00 2001 From: greta Date: Thu, 25 Jul 2024 13:39:57 +0200 Subject: [PATCH] fix: add a try and catch for delete versioning Signed-off-by: greta --- apps/files_versions/lib/Storage.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 07bd6b164d273..d01d6afd3960d 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -61,6 +61,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\StorageInvalidException; @@ -626,8 +627,12 @@ public static function expireOlderThanMaxForUser($uid) { $versionsMapper->delete($versionEntity); } - $version->delete(); - \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $internalPath, 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]); + try { + $version->delete(); + \OC_Hook::emit('\OCP\Versions', 'delete', ['path' => $internalPath, 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT]); + } catch (NotPermittedException $e) { + \OCP\Server::get(LoggerInterface::class)->error("Missing permissions to delete version: {$internalPath}", ['app' => 'files_versions', 'exception' => $e]); + } } }