mirror of
https://github.com/amiayweb/Hytale-F2P.git
synced 2026-02-26 18:11:46 -03:00
fix: resolve cross-platform EPERM permissions errors
modManager.js: - Switch from hardcoded 'junction' to dynamic symlink type based on OS (fixing Linux EPERM). - Add retry logic for directory removal to handle file locking race conditions. - Improve broken symlink detection during profile sync. gameManager.js: - Implement retry loop (3 attempts) for game directory removal in updateGameFiles to prevent EBUSY/EPERM errors on Windows. paths.js: - Prevent fs.mkdirSync failure in getModsPath by pre-checking for broken symbolic links.
This commit is contained in:
@@ -179,8 +179,17 @@ async function getModsPath(customInstallPath = null) {
|
||||
const profilesPath = path.join(userDataPath, 'Profiles');
|
||||
|
||||
if (!fs.existsSync(modsPath)) {
|
||||
// Ensure the Mods directory exists
|
||||
fs.mkdirSync(modsPath, { recursive: true });
|
||||
// Check for broken symlink to avoid EEXIST/EPERM on mkdir
|
||||
let isBrokenLink = false;
|
||||
try {
|
||||
const stats = fs.lstatSync(modsPath);
|
||||
if (stats.isSymbolicLink()) isBrokenLink = true;
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
if (!isBrokenLink) {
|
||||
// Ensure the Mods directory exists
|
||||
fs.mkdirSync(modsPath, { recursive: true });
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(disabledModsPath)) {
|
||||
fs.mkdirSync(disabledModsPath, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user