Skip to content

Commit

Permalink
Fix moving to trash logic
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Nov 25, 2022
1 parent 2699fc1 commit 9e1b0ff
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
20 changes: 18 additions & 2 deletions extensions/file-manager/delete.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ my $mkpath_ = sub {
my $rs = mkpath($dir, { owner => int($in{'uid'}), group => int($in{'guid'}) });
return $rs;
};
my $etrashed = 0;

foreach my $name (@entries_list) {
my $name_ = $name;
Expand Down Expand Up @@ -59,7 +60,21 @@ foreach my $name (@entries_list) {
&$mkpath_($tdir);
}
if (!move("$cwd/$name", $tfile || "$tdir/$name")) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));

# Do not throw an error when moving .Trash inside the .Trash
if (&is_under_directory("$cwd/$name", $tfile || "$tdir/$name")) {
# If .Trash the only one in list, delete it
if (scalar(@entries_list) == 1) {
if (!&unlink_file("$cwd/$name")) {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));
} else {
$etrashed = 1;
push(@deleted_entries, $name);
}
}
} else {
$errors{$name_} = lc($text{'error_delete'} . lc(" - $!"));
}
} else {
push(@deleted_entries, $name);
}
Expand All @@ -76,4 +91,5 @@ if ($fsid) {
cache_search_delete($fsid, \@deleted_entries);
}

redirect_local('list.cgi?path=' . urlize($path) . '&module=filemin' . '&error=' . get_errors(\%errors) . extra_query());
redirect_local('list.cgi?path=' .
urlize($path) . '&module=filemin' . '&etrashed=' . $etrashed . '&error=' . get_errors(\%errors) . extra_query());
10 changes: 4 additions & 6 deletions extensions/file-manager/file-manager-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,7 @@ sub print_content
if ($userconfig{'columns'} =~ /size/) {
my $size = &theme_nice_size_local($list[$count - 1][8]);
push @row_data,
(
"<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'theme_xhred_filemanager_global_size_in_bytes'}<br>@{[nice_number($list[$count - 1][8])]}\">"
( "<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'theme_xhred_filemanager_global_size_in_bytes'}<br>@{[nice_number($list[$count - 1][8])]}\">"
. $size . "</span>");
push(@td_tags, 'data-order="' . ($is_link ? 0 : $is_file ? $list[$count - 1][8] : -1) . '" class="col-size"');
}
Expand All @@ -1026,8 +1025,7 @@ sub print_content
$group = $list[$count - 1][6];
}
push @row_data,
(
"<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'filemanager_global_user_group_id'}<br>$list[$count - 1][5]:$list[$count - 1][6]\">"
( "<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'filemanager_global_user_group_id'}<br>$list[$count - 1][5]:$list[$count - 1][6]\">"
. $user . ':' . $group . "</span>");
push(@td_tags, 'class="col-ownership"');
}
Expand Down Expand Up @@ -1057,8 +1055,7 @@ sub print_content
my $mod_time = POSIX::strftime('%Y/%m/%d - %T', localtime($list[$count - 1][10]));
my $change_time = POSIX::strftime('%Y/%m/%d - %T', localtime($list[$count - 1][11]));
push @row_data,
(
"<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'filemanager_global_access_change_time'}<br>$access_time<br>$change_time\">"
( "<span data-toggle=\"tooltip\" data-html=\"true\" data-title=\"$text{'filemanager_global_access_change_time'}<br>$access_time<br>$change_time\">"
. $mod_time . "</span>");
push(@td_tags, 'data-order="' . ($list[$count - 1][10]) . '" class="col-time"');
}
Expand All @@ -1076,6 +1073,7 @@ sub print_content
$list_data{'pagination_requested'} = $in{'paginate'};
$list_data{'totals'} = $totals;
$list_data{'searched'} = $query ? 1 : 0;
$list_data{'etrashed'} = $in{'etrashed'} ? 1 : 0;
$list_data{'flush'} = test_all_items_query() ? 1 : 0;
$list_data{'flush_reset'} = $in{'flush_reset'} ? 1 : 0;
$list_data{'udata'} = { user => $remote_user_info[0],
Expand Down
2 changes: 1 addition & 1 deletion extensions/file-manager/file-manager-reinit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified extensions/file-manager/file-manager-reinit.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion extensions/file-manager/file-manager.min.js

Large diffs are not rendered by default.

Binary file modified extensions/file-manager/file-manager.min.js.gz
Binary file not shown.
Binary file modified unauthenticated/js/bundle.min.js.gz
Binary file not shown.

0 comments on commit 9e1b0ff

Please sign in to comment.