fix: false warn about DownloadPath at startup

This commit is contained in:
MasterAcnolo
2026-08-14 17:18:28 +02:00
parent 6c517255e3
commit 7f8d018bcb

View File

@@ -56,28 +56,23 @@ function validateDownloadPath(userPath) {
if (!userPath) return getDefaultDownloadPath(); if (!userPath) return getDefaultDownloadPath();
try { try {
const absolutePath = path.resolve(userPath);
/** if (!fs.existsSync(absolutePath)) {
* Resolves filesystem symlinks to ensure canonical absolute path. fs.mkdirSync(absolutePath, { recursive: true });
* Required to prevent path traversal or alias bypass. logger.info(`Download folder created: ${absolutePath}`);
*/
const resolved = fs.realpathSync(path.resolve(userPath));
if (!fs.existsSync(resolved)) {
fs.mkdirSync(resolved, { recursive: true });
logger.info(`Download folder created: ${resolved}`);
} }
const real = fs.realpathSync(resolved); const real = fs.realpathSync(absolutePath);
if (!isSafePath(resolved)) { if (!isSafePath(real)) {
throw new Error("Path not allowed: system folders are blocked!"); throw new Error("Path not allowed: system folders are blocked!");
} }
return real; return real;
} }
catch (err) {
catch (err) {
/** /**
* Handles invalid filesystem paths, permissions issues, or resolution failures. * Handles invalid filesystem paths, permissions issues, or resolution failures.
* Logs diagnostic information before propagating a sanitized error. * Logs diagnostic information before propagating a sanitized error.