summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorCarl Csaposs <carl@csaposs.com>2022-05-20 00:43:12 +0000
committerCarl Csaposs <carl@csaposs.com>2022-07-04 17:13:15 +0000
commit6f6ccfcc18983c9fe4da383e1047f79dcfdd1042 (patch)
tree6a5885c1935e9dbbe65c36ef6865cf43c7c13e1e /apps/files_trashbin/lib
parentec465bf247ec2e9fd3df13f6a289ecc5fb6e4e2a (diff)
downloadnextcloud-server-6f6ccfcc18983c9fe4da383e1047f79dcfdd1042.tar.gz
nextcloud-server-6f6ccfcc18983c9fe4da383e1047f79dcfdd1042.zip
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 <carl@csaposs.com>
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/Command/RestoreAllFiles.php6
1 files changed, 5 insertions, 1 deletions
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");