debug duplicate posts

master
adb 3 years ago
parent 29eb393717
commit 1e25cba824

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

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

Loading…
Cancel
Save