From d72e0a441864a8c183caaa854122b0572cb376ea Mon Sep 17 00:00:00 2001 From: mikiher Date: Wed, 7 Aug 2024 21:18:53 +0300 Subject: [PATCH] Fix path normalization to support UNC paths --- server/utils/fileUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/utils/fileUtils.js b/server/utils/fileUtils.js index c68d2786..e4bb53a0 100644 --- a/server/utils/fileUtils.js +++ b/server/utils/fileUtils.js @@ -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 @@ -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) { @@ -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 = ''