PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[Peek] Slow and non-standard progress updates for folder size calculations

Open daverayment opened this issue 1 year ago • 0 comments

Microsoft PowerToys version

0.83.0

Installation method

PowerToys auto-update

Running as admin

No

Area(s) with issue?

Peek

Steps to reproduce

When using Peek to view a folder's details, the UnsupportedFilePreviewer is used (when the folder isn't a Windows 'special' folder). This class uses a DispatcherTimer to handle tracking the potentially long-running operation of calculating the size of all files in that folder and all its subfolders. The timer has a 500ms delay and tick interval. This means that for folders with large numbers of files, or where the enumeration takes a long time, there is a half-second delay before any size information is shown, and subsequent updates appear sluggish.

Additionally, the file enumeration code itself is recursive and does not take advantage of .NET Core 2.1 and later's DirectoryInfo.EnumerateFiles, which is faster and simpler to use.

Finally, ThrowIfCancellationRequested is called on the task's cancellation token for every single file operation, which is unnecessary.

In summary, the class would benefit from using System.Progress for reporting progress for async tasks, and use the more modern EnumerateFiles for the size calculation, for reasons of efficiency and improved UI responsiveness.

✔️ Expected Behavior

Progress is immediately shown and regular UI updates are provided.

❌ Actual Behavior

It takes half a second to show the initial size information and further updates are sluggish.

Other Software

No response

daverayment avatar Sep 22 '24 21:09 daverayment