Incorrect normalization to UNC paths causes failed library scan #2913
Labels
enhancement
New feature or request
needs-triage
Needs to be triaged by a developer and assigned a release
What happened?
Kavita fails to access files in folders added to libraries by UNC paths (e.g.
\\Server\Share\Directory\File
), so series in those folders cannot be discovered during library scans.The problem is two-fold:
A. Web UI applies incorrect path normalization before sending API request
At library-settings-modal.components.ts:286 and :297:
This truncates leading
\\
into\
, so UNC path\\Server\Share\Directory\File
becomes\Server\Share\Directory\File
, which is then sent to the backend. The latter is no longer a UNC path and will be interpreted as a relative path instead.Entering the UNC path with forward slashes (
//Server/Share/Directory/File
, uncanonical) avoids the truncation and works around this problem, which brings us to:B. Backend applies incorrect path normalization during library scan
At Parser.cs:1190:
Any double forward slashes will be combines into one. So
//Server/Share/Directory/File
would be normalized into/Server/Share/Directory/File
. This is again interpreted as a relative path, and upon file access the .NET BCL will expand it into an absolute path based on the application's current drive, which by default is the drive where the application's executable file is located. For example, ifkavita.exe
is located atC:\Kavita\kavita.exe
, the actual file Kavita tries to access will beC:/Server/Share/Directory/File
. Such files most probably do not exist, so access will fail.Removing the second
Replace()
call solves the problem for me, so I believe the changes required to address those problems should be trivial, and I'm glad to make such contributions. However, seeing it as a potentially breaking change, and that there are tests for this specific behavior, I would really like to have a discussion first in order to know more background for those decisions.What did you expect?
There should be end-to-end support for UNC paths, so users can add folders hosted on remote file shares to their libraries.
Kavita Version Number - If you don not see your version number listed, please update Kavita and see if your issue still persists.
0.8.1 - Stable
What operating system is Kavita being hosted from?
Windows
If the issue is being seen on Desktop, what OS are you running where you see the issue?
None
If the issue is being seen in the UI, what browsers are you seeing the problem on?
No response
If the issue is being seen on Mobile, what OS are you running where you see the issue?
None
If the issue is being seen on the Mobile UI, what browsers are you seeing the problem on?
No response
Relevant log output
Additional Notes
One workaround is to map the file shares to drive letters and access the files by them. This should be trivial for interactive workstation deployments but can be more involved for headless server deployments using Windows service wrappers.
Some service wrapper implementations provide features to facilitate this. For example, WinSW seems to support this scenario. However, I don't see any information on this for Shawl, so the workaround might not always be available.
The text was updated successfully, but these errors were encountered: