From ff502e17f3609078434793761d20f402997e25d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:00:54 +0100 Subject: [PATCH] feat: versioned storages are expected to handle retainVersions themselves --- apps/files_trashbin/lib/Trashbin.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index e4d7e67c248f..057e72ba7c91 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -46,6 +46,7 @@ use OCP\Encryption\Keys\IStorage; use OCP\Files\ForbiddenException; use OCP\Files\NotFoundException; +use OCP\Files\Storage\IVersionedStorage; use OCP\Files\StorageNotAvailableException; use OCP\Lock\LockedException; use OCP\User; @@ -375,11 +376,13 @@ public static function move2trash($file_path) { 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp) ]); - self::retainVersions($filename, $owner, $ownerPath, $timestamp, $sourceStorage); + if (!$sourceStorage->instanceOfStorage(IVersionedStorage::class)) { + self::retainVersions($filename, $owner, $ownerPath, $timestamp, $sourceStorage); - // if owner !== user we need to also add a copy to the owners trash - if ($user !== $owner) { - self::copyFilesToUser($ownerPath, $owner, $file_path, $user, $timestamp); + // if owner !== user we need to also add a copy to the owners trash + if ($user !== $owner) { + self::copyFilesToUser($ownerPath, $owner, $file_path, $user, $timestamp); + } } }