Arlodotexe / OwlCore.Storage

The most flexible file system abstraction, ever. Built in partnership with the UWP Community.
15 stars 4 forks source link

Remove redundant validation when enumerating files & folders in SystemFile/SystemFolder. #56

Closed itsWindows11 closed 6 days ago

itsWindows11 commented 1 week ago

Currently, when enumerating or copying files, we are checking whether the file exists or not in the constructor. This can cause unnecessary huge disk I/O overhead especially with large folders.

A new internal constructor is created specifically to prevent this scenario (only creates an instance with the necessary item info, nothing else), since in these cases we already know that the file/folder indeed exists.

cc. @HEIC-to-JPEG-Dev feel free to review.

itsWindows11 commented 1 week ago

I've merged the PR with the requested changes.

itsWindows11 commented 1 week ago

Just added even more optimizations that should get the enumeration time in tests to less than 1ms in most cases. Using StorableType.All mode we are now using the DirectoryInfo to enumerate file system info entries, which makes it easier to distinguish between files and folders by just accessing the attributes instead of another File.Exists() call.