Skip to content

Commit 2058bfd

Browse files
authored
Merge pull request NetrisTV#150 from HardBoiledSmith/DEV-18306
DEV-18306 [ramiel] Error: ENOENT: no such file or directory, scandir '/tmp/ramiel_file_lock'
2 parents 7c9b069 + 8b35952 commit 2058bfd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/server/Utils.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class Utils {
101101
}
102102

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

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

132132
public static fileUnlock(file: string): void {
133-
fs.unlinkSync(`${Utils.PathToFileLock}/${file}`);
133+
fs.unlinkSync(`${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}/${file}`);
134134
}
135135

136136
public static async initFileLock(): Promise<void> {
137137
try {
138-
if (fs.existsSync(Utils.PathToFileLock)) {
139-
fs.rmdirSync(Utils.PathToFileLock, { recursive: true });
140-
}
141138
fs.mkdirSync(Utils.PathToFileLock);
139+
} catch (e) {}
140+
141+
const pp = `${Utils.PathToFileLock}/${Config.getInstance().getServerPort()}`;
142+
try {
143+
if (fs.existsSync(pp)) {
144+
fs.rmdirSync(pp, { recursive: true });
145+
}
146+
fs.mkdirSync(pp);
142147
} catch (e) {
143-
console.log(e);
148+
console.error(e);
144149
}
145150
}
146151

0 commit comments

Comments
 (0)