From 6f6ccfcc18983c9fe4da383e1047f79dcfdd1042 Mon Sep 17 00:00:00 2001 From: Carl Csaposs Date: Fri, 20 May 2022 00:43:12 +0000 Subject: Sort files by deletion time before restoring in RestoreAllFiles Restoring in order of most recently deleted preserves nested file paths. See https://github.com/nextcloud/server/issues/31200#issuecomment-1130358549 Signed-off-by: Carl Csaposs --- apps/files_trashbin/lib/Command/RestoreAllFiles.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apps/files_trashbin/lib/Command') diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php index 43e9363327b..748ead798d8 100644 --- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php +++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php @@ -129,7 +129,11 @@ class RestoreAllFiles extends Base { \OC_Util::setupFS($uid); \OC_User::setUserId($uid); - $filesInTrash = Helper::getTrashFiles('/', $uid, 'mtime'); + // Sort by most recently deleted first + // (Restoring in order of most recently deleted preserves nested file paths. + // See https://github.com/nextcloud/server/issues/31200#issuecomment-1130358549) + $filesInTrash = Helper::getTrashFiles('/', $uid, 'mtime', true); + $trashCount = count($filesInTrash); if ($trashCount == 0) { $output->writeln("User has no deleted files in the trashbin"); -- cgit v1.2.3