mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Fix dirWatch[].deleteAfter=true not always being deleted
This commit is contained in:
parent
aa7d17443e
commit
51c6c5a4ce
|
|
@ -99,10 +99,10 @@ class DirWatch {
|
|||
|
||||
await metaWatcher.close();
|
||||
|
||||
let meta;
|
||||
|
||||
try {
|
||||
meta = JSON.parse(fs.readFileSync(metaFile, 'utf8'));
|
||||
const meta = JSON.parse(fs.readFileSync(metaFile, 'utf8'));
|
||||
|
||||
await this.app.controller.importTrunkRecorder(audio, audioName, audioType, system, meta);
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error loading file ${metaFile}`);
|
||||
|
|
@ -110,12 +110,8 @@ class DirWatch {
|
|||
return;
|
||||
}
|
||||
|
||||
if (meta) {
|
||||
await this.app.controller.importTrunkRecorder(audio, audioName, audioType, system, meta);
|
||||
|
||||
if (dirWatch.deleteAfter) {
|
||||
this.unlink(metaFile);
|
||||
}
|
||||
if (dirWatch.deleteAfter) {
|
||||
this.unlink(metaFile);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -138,10 +134,10 @@ class DirWatch {
|
|||
|
||||
await metaWatcher.close();
|
||||
|
||||
let meta;
|
||||
|
||||
try {
|
||||
meta = JSON.parse(fs.readFileSync(metaFile, 'utf8'));
|
||||
const meta = JSON.parse(fs.readFileSync(metaFile, 'utf8'));
|
||||
|
||||
await this.app.controller.importSdrtrunk(audio, audioName, audioType, system, meta);
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error loading file ${metaFile}`);
|
||||
|
|
@ -149,8 +145,6 @@ class DirWatch {
|
|||
return;
|
||||
}
|
||||
|
||||
await this.app.controller.importSdrtrunk(audio, audioName, audioType, system, meta);
|
||||
|
||||
if (dirWatch.deleteAfter) {
|
||||
this.unlink(metaFile);
|
||||
}
|
||||
|
|
@ -185,7 +179,7 @@ class DirWatch {
|
|||
|
||||
unlink(filename) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
setTimeout(() => fs.unlinkSync(filename), 1000);
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Unable to delete ${filename}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue