1
0
Fork 0

fix negative running single user db save fail

This commit is contained in:
lightling 2024-02-15 23:34:43 -05:00
parent cb4effa348
commit 3f7f929972
2 changed files with 6 additions and 11 deletions

View file

@ -10,7 +10,6 @@
"locals().get('bitrate') == 0": "{author['name']}-{tweet_id}-{date:%Y%m%d_%H%M%S}-gif{num}.{extension}", "locals().get('bitrate') == 0": "{author['name']}-{tweet_id}-{date:%Y%m%d_%H%M%S}-gif{num}.{extension}",
"": "{author['name']}-{tweet_id}-{date:%Y%m%d_%H%M%S}-img{num}.{extension}" "": "{author['name']}-{tweet_id}-{date:%Y%m%d_%H%M%S}-img{num}.{extension}"
}, },
"cookies": "$HOME/.config/gallery-dl/twitter-cookies.txt",
"timeline": { "timeline": {
"strategy": "media" "strategy": "media"
}, },

View file

@ -47,17 +47,13 @@ export const getMany = (userDb, threadMax, directory, mode) => new Promise((reso
const get = () => { const get = () => {
const checkError = (currentIndex, type, codeOrError) => { const checkError = (currentIndex, type, codeOrError) => {
userDb[currentIndex].logs.push(codeOrError.toString()) userDb[currentIndex].logs.push(codeOrError.toString());
if (typeof codeOrError === 'number' && userDb[currentIndex].running) { if (typeof codeOrError === 'number' && userDb[currentIndex].running === mode) {
userDb[currentIndex].running = false; userDb[currentIndex].running = false;
onFinish(currentIndex, type);
}
};
const onFinish = (currentIndex, type) => {
log(ctx, `Finished ${userDb[currentIndex].user} under ${mode} mode.${type === 'close' ? '' : ' (Closed due to ' + type + ')'}`);
--running; --running;
log(ctx, `Finished (via ${type}) ${userDb[currentIndex].user} under ${mode} mode. ${running} processes still running.`);
get(); get();
}
}; };
while (running < threadMax && index < userDb.length) { while (running < threadMax && index < userDb.length) {
@ -69,7 +65,7 @@ export const getMany = (userDb, threadMax, directory, mode) => new Promise((reso
}; };
let proc = getUser(userDb[currentIndex].user, directory, modeParams); let proc = getUser(userDb[currentIndex].user, directory, modeParams);
userDb[currentIndex].running = true; userDb[currentIndex].running = mode;
proc.stdout.on('data', data => { proc.stdout.on('data', data => {
userDb[currentIndex].logs.push(trimNewlinesEnd(data)); userDb[currentIndex].logs.push(trimNewlinesEnd(data));
}); });