Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Delay enumeration of directory until IDirectoryContents enumerated #224

Closed
davidfowl opened this issue Aug 8, 2016 · 2 comments
Closed
Assignees

Comments

@davidfowl
Copy link
Member

Not sure why we do this inline, but I was profiling the static file middleware and saw enumeration even though it's just checking for directory existence:

https://github.com/aspnet/FileSystem/blob/dev/src/Microsoft.Extensions.FileProviders.Physical/PhysicalFileProvider.cs#L219-L236

https://github.com/aspnet/StaticFiles/blob/dev/src/Microsoft.AspNetCore.StaticFiles/DefaultFilesMiddleware.cs#L69-L95

@davidfowl davidfowl changed the title Delay enumeration of directory until Directory enumerated Delay enumeration of directory until IDirectoryContents enumerated Aug 8, 2016
@Yves57
Copy link

Yves57 commented Aug 28, 2016

I just had a somewhat similar problem in a WebDAV middleware implementation: I just want to check a path validity, and if this path represents a file or a directory.
Calling GetFileInfo works for the files but not for the directories. So if it fails, I have to call GetDirectoryContents to check if it is a directory. And of course it enumerates all child entries for nothing in my case.

So just for curiosity, why GetFileInfo does not return a valid IFileInfo for a directory? For performance reasons in case of the path is invalid?

@natemcmaster
Copy link
Contributor

Might be room for even more improvement that #237. See #237 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants