UseStaticFiles should provide a case insensitive option in StaticFileOptions
Is your feature request related to a problem? Please describe.
My team ran into an issue where we develop on windows with case insensitive file system and returning static files using lower case links but when deploying on linux (case sensitive file system) in docker the same links no longer worked as the files had camel case on disk
Describe the solution you'd like
Add a boolean value to StaticFileOptions to enable static files to resolve files on disk ignoring file system case thus having the same behavior on windows and linux.
Additional context
Example file: /wwwroot/MyTestFile.txt Link http://localhost/mytestfile.txt works on windows doesnt work on linux
The file lookup is managed by the IFileProvider implemented by PhysicalFileProvider in this example. https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs
Case in-sensitivity isn't something StaticFiles can fake from the top down, you'd need this option on the underlying file APIs first.
Recommend transferring this to Runtime.
Transferring this to runtime. The change that would be needed here is to have a case-insensitive mode to file providers.
Having said that, we already know there are case-sensitive file systems in use (Linux, as you noted) and making the file providers case-insensitive even when on a case-sensitive file system is very tricky and disruptive.
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.
It's not clear what the API request is here. Can you make a formal API request?
Also, keep in mind that even on windows you can now make the file system case-sensitive so the value of such a feature here might be diminished.
I'm not going to back this at all, but in fact this is to my eyes a very clear item. API surface is something like bool ForceCaseInsensitive {get;set;} = false; Trying to provide case insensitive APIs in general is very hard for lots of obvious reasons, but it's easy enough to do on a pure reader. Or maybe ForceLowerCase is better; hard to tell.
We have issues tracking this request on dotnet/runtime repo already: https://github.com/dotnet/runtime/issues/23871, https://github.com/dotnet/runtime/issues/14321, https://github.com/dotnet/runtime/issues/17873
@Tratcher what is the underlying API that would end up calling a new API that allows for checking case sensitivity?
Here: https://github.com/dotnet/runtime/blob/75090807267d3a06c9ad806c6d33e773f69675bc/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs#L243-L265
Case sensitivity would be a new option on the PhysicalFileProvider, and it would use that when creating a new FileInfo.
Also here when listing the contents of directories: https://github.com/dotnet/runtime/blob/75090807267d3a06c9ad806c6d33e773f69675bc/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs#L307 https://github.com/dotnet/runtime/blob/75090807267d3a06c9ad806c6d33e773f69675bc/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/PhysicalDirectoryContents.cs#L61
Seems like a new API addition for System.IO.
cc: @carlossanlop @Jozkee
Any new information here?
We came across this in our application as well. Any update on this would be appreciated
Yeah, any update on this would help a lot...
@MarvinKlein1508 , @0x6DD8 An implementation of static file provider is about 600 lines of mostly boilerplate code; maybe less in truly modern C#.
After 3 years, there is still no solution for linux?
Is there a proposal?
@davidfowl : That's trivial.
@jhudsoncedaron Did you send a pull request with the solution?
@davidfowl That's a different question. I'm not going to lift a finger unless it's approved first. A proposal is trivial. Getting a PR approved for a request that isn't approved first is not.
I guess I missed the proposal. I re-read this a couple of times and I see this suggestion but I don't know what the end to end proposal is for this feature. How would it work?
It's pretty clear that OP wants to develop on Windows and run the output on Linux. So you run the directory descent piecewise matching case insensitive by matching the output of directory enumeration. It would be easier if I could use my own libraries because System.IO.Directory is pretty bad; but that's a different problem.
So the file provider enumerates the entire directory tree up front? If not, what happens in GetFileInfo?