Skip to content

Commit d10a581

Browse files
authored
Fix: Fixed issue where process details weren't displayed when deleting folders with open files (#17830)
1 parent 3ff9c6d commit d10a581

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Files.App/Utils/Storage/Operations/ShellFilesystemOperations.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,26 @@ public async Task<IStorageHistory> DeleteItemsAsync(IList<IStorageItemWithPath>
415415
else if (deleteResult.Items.Any(x => CopyEngineResult.Convert(x.HResult) == FileSystemStatusCode.InUse))
416416
{
417417
var failedSources = deleteResult.Items.Where(x => CopyEngineResult.Convert(x.HResult) == FileSystemStatusCode.InUse);
418-
var filePath = failedSources.Select(x => x.Source); // When deleting only source can be in use but shell returns COPYENGINE_E_SHARING_VIOLATION_DEST for folders
418+
419+
var filesToCheck = new List<string>();
420+
foreach (var failedSource in failedSources)
421+
{
422+
if (Directory.Exists(failedSource.Source))
423+
{
424+
try
425+
{
426+
var files = Directory.EnumerateFiles(failedSource.Source, "*", SearchOption.AllDirectories);
427+
filesToCheck.AddRange(files);
428+
}
429+
catch { }
430+
}
431+
else if (File.Exists(failedSource.Source))
432+
{
433+
filesToCheck.Add(failedSource.Source);
434+
}
435+
}
436+
437+
var filePath = filesToCheck.Any() ? filesToCheck : failedSources.Select(x => x.Source);
419438
var lockingProcess = WhoIsLocking(filePath);
420439

421440
switch (await GetFileInUseDialog(filePath, lockingProcess))

0 commit comments

Comments
 (0)