From 746b8e83bc6c360f76c2fdace3e9e2d08c988a08 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 9336819b06e3..5320a583e047 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -47,6 +47,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; @@ -376,11 +377,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); + } } }