-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UseStaticFiles should provide a case insensitive option in StaticFileOptions #35128
Comments
The file lookup is managed by the IFileProvider implemented by PhysicalFileProvider in this example. 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 |
Here: runtime/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs Lines 243 to 265 in 7509080
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: runtime/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs Line 307 in 7509080
Line 61 in 7509080
|
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? |
"So the file provider enumerates the entire directory tree up front?" If it were my codebase that's how I'd do it; but that's because I know I can just not handle updates to the tree while running. If that's not going to work out for you gotta do the piecewise descent and resolve in GetFileInfo. This isn't too expensive on the server. samba gets away with it all the time. Now that you know what a proposal looks like you can decide whether you want it or not. |
I'm just trying to understand your idea, so I'm trying to piece it together from the clues you are dropping. So the idea is the enumerate and cache the files in a case insensitive set? Did I miss something? What about file changes? |
I think you missed nothing. "What about file changes?" If you have to handle this you can't cache. I simply don't have the toolset to know. I solved this problem by case normalization at build time and I am already using my own provider due to a bug that was closed wontfix so there it will remain. Case insensitive file open is an exercise that should take an hour to solve. |
OK, I'll leave this open, and I'm still confused as to what your concrete proposal is for this. |
It sounds like we'd have to recursively enumerate directories along the path and do a manual case-insensitive search at each level for a match. That can get very expensive per request, especially if the folder structure is deep or folders contain many files. Performance wise this seems untenable for more than a few files without cache + refresh. For what it's worth, this whole solution could be built into a custom version of PhysicalFileProvider, it wouldn't require any changes from StaticFiles. |
What if, instead of "case insensitive" you made it transform everything to lowercase? |
I was able to solve for this issue using https://github.com/XiaoFaye/CaseInsensitiveStaticFile |
I run into this issue as well, dockerizing asp.net core app that was previously running on Windows Server IIS, now having issues with case sensitive paths in static files, I would welcome some bool option to treat paths for static files as case insensitive. |
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 text was updated successfully, but these errors were encountered: