Skip to content

Commit 86dcfa3

Browse files
Fix: Fixed issue where confirm to delete would show even with the setting turned off (#10893)
1 parent 447396d commit 86dcfa3

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/Files.App/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
116116
var deleteFromRecycleBin = source.Select(item => item.Path).Any(path => recycleBinHelpers.IsPathUnderRecycleBin(path));
117117
var canBeSentToBin = !deleteFromRecycleBin && await recycleBinHelpers.HasRecycleBin(source.FirstOrDefault()?.Path);
118118

119-
if (showDialog && ((!permanently && !canBeSentToBin) || UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog)) // Check if the setting to show a confirmation dialog is on
119+
if (showDialog && UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog) // Check if the setting to show a confirmation dialog is on
120120
{
121121
var incomingItems = new List<BaseFileSystemDialogItemViewModel>();
122-
List<ShellFileItem> binItems = null;
122+
List<ShellFileItem>? binItems = null;
123123
foreach (var src in source)
124124
{
125125
if (recycleBinHelpers.IsPathUnderRecycleBin(src.Path))
@@ -147,13 +147,15 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
147147
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();
148148

149149
if (await dialogService.ShowDialogAsync(dialogViewModel) != DialogResult.Primary)
150-
{
151150
return ReturnResult.Cancelled; // Return if the result isn't delete
152-
}
153151

154152
// Delete selected items if the result is Yes
155153
permanently = dialogViewModel.DeletePermanently;
156154
}
155+
else
156+
{
157+
permanently |= !canBeSentToBin; // delete permanently if recycle bin is not supported
158+
}
157159

158160
// post the status banner
159161
var banner = PostBannerHelpers.PostBanner_Delete(source, returnStatus, permanently, false, 0);
@@ -169,9 +171,7 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
169171
await Task.Yield();
170172

171173
if (!permanently && registerHistory)
172-
{
173174
App.HistoryWrapper.AddHistory(history);
174-
}
175175
var itemsDeleted = history?.Source.Count ?? 0;
176176

177177
source.ForEach(x => App.JumpList.RemoveFolder(x.Path)); // Remove items from jump list

src/Files.App/Helpers/RecycleBinHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
147147
return contentDialog;
148148
}
149149

150-
public async Task<bool> HasRecycleBin(string path)
150+
public async Task<bool> HasRecycleBin(string? path)
151151
{
152152
if (string.IsNullOrEmpty(path) || path.StartsWith(@"\\?\", StringComparison.Ordinal))
153153
return false;

src/Files.Shared/Enums/CopyEngineResult.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public static FileSystemStatusCode Convert(int? hres)
6565
CopyEngineResult.COPYENGINE_E_NET_DISCONNECT_DEST => FileSystemStatusCode.NotFound,
6666
CopyEngineResult.COPYENGINE_E_NET_DISCONNECT_SRC => FileSystemStatusCode.NotFound,
6767
CopyEngineResult.COPYENGINE_E_CANT_REACH_SOURCE => FileSystemStatusCode.NotFound,
68-
CopyEngineResult.COPYENGINE_E_RECYCLE_BIN_NOT_FOUND => FileSystemStatusCode.NotFound,
6968
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_NORMAL => FileSystemStatusCode.AlreadyExists,
7069
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_READONLY => FileSystemStatusCode.AlreadyExists,
7170
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_SYSTEM => FileSystemStatusCode.AlreadyExists,

0 commit comments

Comments
 (0)