Skip to content

Commit

Permalink
Merge pull request NetrisTV#150 from HardBoiledSmith/DEV-18306
Browse files Browse the repository at this point in the history
DEV-18306 [ramiel] Error: ENOENT: no such file or directory, scandir '/tmp/ramiel_file_lock'
  • Loading branch information
yoonjs2 authored Jun 19, 2023
2 parents 7c9b069 + 8b35952 commit 2058bfd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/server/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class Utils {
}

private static checkExpiredFileLock(file: string): void {
const pp = `${Utils.PathToFileLock}/${file}`;
const pp = `${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}/${file}`;
if (!fs.existsSync(pp)) {
return;
}
Expand All @@ -125,22 +125,27 @@ export class Utils {
}

private static fileLock(file: string): void {
const fd = fs.openSync(`${Utils.PathToFileLock}/${file}`, 'wx');
const fd = fs.openSync(`${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}/${file}`, 'wx');
fs.closeSync(fd);
}

public static fileUnlock(file: string): void {
fs.unlinkSync(`${Utils.PathToFileLock}/${file}`);
fs.unlinkSync(`${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}/${file}`);
}

public static async initFileLock(): Promise<void> {
try {
if (fs.existsSync(Utils.PathToFileLock)) {
fs.rmdirSync(Utils.PathToFileLock, { recursive: true });
}
fs.mkdirSync(Utils.PathToFileLock);
} catch (e) {}

const pp = `${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}`;
try {
if (fs.existsSync(pp)) {
fs.rmdirSync(pp, { recursive: true });
}
fs.mkdirSync(pp);
} catch (e) {
console.log(e);
console.error(e);
}
}

Expand Down

0 comments on commit 2058bfd

Please sign in to comment.