debug duplicate posts

This commit is contained in:
0xADB 2021-03-15 09:33:43 +01:00
parent 29eb393717
commit 1e25cba824
2 changed files with 7 additions and 6 deletions

View File

@ -16,9 +16,10 @@ export function loadData(path) {
}
}
export function getStat(path) {
fs.stat(path, (err, stat) => {
if(err == null) return true;
if(err.code === 'ENOENT') return false;
return err.code;
});
try {
return fs.existsSync(path) === true;
} catch(err) {
console.error(err)
return false;
}
}

View File

@ -20,7 +20,7 @@ export class mastodonMemeBot {
return;
}
let filepath = `./media/${sub.url.split(/[/]+/).pop()}`;
if (getStat(filepath) === true) {
if (getStat(filepath)) {
console.log("post already exists, fetching new sub");
this.postRandomMeme(callback);
return;