[PR #3254] [MERGED] Fix path normalization to support UNC paths #3916

Closed
opened 2026-04-25 00:17:33 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3254
Author: @mikiher
Created: 8/7/2024
Status: Merged
Merged: 8/7/2024
Merged by: @advplyr

Base: masterHead: unc-path-support


📝 Commits (1)

  • d72e0a4 Fix path normalization to support UNC paths

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 server/utils/fileUtils.js (+4 -2)

📄 Description

This fixes #640.

UNC Paths are the standard way to refer to shared netowrk resources on Windows.
Several users have reported that these paths are not supprted in Audiobookshelf (specifically, when you specify a UNC path to a library folder, no error is generated, but scanning of that folder always fails, with weird non-existent library item paths showing up in the scan).

The reason for the bug was posix normalization. Current normalization just changes all backslashes to slashes, which is OK for most Windows paths and doesn't change path semantics. UNC paths, however, begin with a double backslash (\\), and when you change it to double slash (//), the path semantic is changed and subsequent file/path operations no longer interpret the path as a UNC path.

To fix this, I changed posix path normalization to preserve the double backslash for UNC paths, while still normalizing all other backslashes to slashes.

This seems to fully resolve the issue, and users can now specify UNC paths when setting up library folders.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/3254 **Author:** [@mikiher](https://github.com/mikiher) **Created:** 8/7/2024 **Status:** ✅ Merged **Merged:** 8/7/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `unc-path-support` --- ### 📝 Commits (1) - [`d72e0a4`](https://github.com/advplyr/audiobookshelf/commit/d72e0a441864a8c183caaa854122b0572cb376ea) Fix path normalization to support UNC paths ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/fileUtils.js` (+4 -2) </details> ### 📄 Description This fixes #640. UNC Paths are the standard way to refer to shared netowrk resources on Windows. Several users have reported that these paths are not supprted in Audiobookshelf (specifically, when you specify a UNC path to a library folder, no error is generated, but scanning of that folder always fails, with weird non-existent library item paths showing up in the scan). The reason for the bug was posix normalization. Current normalization just changes all backslashes to slashes, which is OK for most Windows paths and doesn't change path semantics. UNC paths, however, begin with a double backslash (`\\`), and when you change it to double slash (`//`), the path semantic is changed and subsequent file/path operations no longer interpret the path as a UNC path. To fix this, I changed posix path normalization to preserve the double backslash for UNC paths, while still normalizing all other backslashes to slashes. This seems to fully resolve the issue, and users can now specify UNC paths when setting up library folders. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:17:33 +02:00
adam closed this issue 2026-04-25 00:17:33 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3916