Skip to content

Commit

Permalink
Merge pull request #3254 from mikiher/unc-path-support
Browse files Browse the repository at this point in the history
Fix path normalization to support UNC paths
  • Loading branch information
advplyr authored Aug 7, 2024
2 parents 2c8ebd4 + d72e0a4 commit 91dc6ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { AudioMimeType } = require('./constants')
*/
const filePathToPOSIX = (path) => {
if (!global.isWin || !path) return path
return path.replace(/\\/g, '/')
return path.startsWith('\\\\') ? '\\\\' + path.slice(2).replace(/\\/g, '/') : path.replace(/\\/g, '/')
}
module.exports.filePathToPOSIX = filePathToPOSIX

Expand Down Expand Up @@ -169,7 +169,7 @@ async function recurseFiles(path, relPathToReplace = null) {
extensions: true,
deep: true,
realPath: true,
normalizePath: true
normalizePath: false
}
let list = await rra.list(path, options)
if (list.error) {
Expand All @@ -186,6 +186,8 @@ async function recurseFiles(path, relPathToReplace = null) {
return false
}

item.fullname = filePathToPOSIX(item.fullname)
item.path = filePathToPOSIX(item.path)
const relpath = item.fullname.replace(relPathToReplace, '')
let reldirname = Path.dirname(relpath)
if (reldirname === '.') reldirname = ''
Expand Down

0 comments on commit 91dc6ee

Please sign in to comment.