mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11:15 +02:00
fix: false warn about DownloadPath at startup
This commit is contained in:
@@ -56,28 +56,23 @@ function validateDownloadPath(userPath) {
|
||||
if (!userPath) return getDefaultDownloadPath();
|
||||
|
||||
try {
|
||||
const absolutePath = path.resolve(userPath);
|
||||
|
||||
/**
|
||||
* Resolves filesystem symlinks to ensure canonical absolute path.
|
||||
* Required to prevent path traversal or alias bypass.
|
||||
*/
|
||||
const resolved = fs.realpathSync(path.resolve(userPath));
|
||||
|
||||
if (!fs.existsSync(resolved)) {
|
||||
fs.mkdirSync(resolved, { recursive: true });
|
||||
logger.info(`Download folder created: ${resolved}`);
|
||||
if (!fs.existsSync(absolutePath)) {
|
||||
fs.mkdirSync(absolutePath, { recursive: true });
|
||||
logger.info(`Download folder created: ${absolutePath}`);
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
|
||||
return real;
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
catch (err) {
|
||||
/**
|
||||
* Handles invalid filesystem paths, permissions issues, or resolution failures.
|
||||
* Logs diagnostic information before propagating a sanitized error.
|
||||
|
||||
Reference in New Issue
Block a user