Commit e1b00275 authored by Johannes Zellner's avatar Johannes Zellner

Ensure we don't sync twice at the same time

parent a3e2acc9
...@@ -147,14 +147,8 @@ function profileUpdate(req, res, next) { ...@@ -147,14 +147,8 @@ function profileUpdate(req, res, next) {
next(new HttpSuccess(202, {})); next(new HttpSuccess(202, {}));
// trigger a sync for the user // kick off a round of syncing for the new github token
tasks.syncStarredByUser(req.user, function (error) { tasks.run();
if (error) console.error(error);
tasks.syncReleasesByUser(req.user, function (error) {
if (error) console.error(error);
});
});
}); });
}); });
} }
......
...@@ -27,8 +27,14 @@ if (CAN_SEND_EMAIL) { ...@@ -27,8 +27,14 @@ if (CAN_SEND_EMAIL) {
} }
const EMAIL_TEMPLATE = handlebars.compile(fs.readFileSync(path.resolve(__dirname, 'notification.template'), 'utf8')); const EMAIL_TEMPLATE = handlebars.compile(fs.readFileSync(path.resolve(__dirname, 'notification.template'), 'utf8'));
var syncTimer = null;
function run() { function run() {
if (syncTimer) {
clearTimeout(syncTimer);
syncTimer = null;
}
console.log('Run periodic tasks...'); console.log('Run periodic tasks...');
syncStarred(function (error) { syncStarred(function (error) {
...@@ -41,7 +47,7 @@ function run() { ...@@ -41,7 +47,7 @@ function run() {
if (error) console.error(error); if (error) console.error(error);
// just keep polling for good // just keep polling for good
setTimeout(run, 60 * 1000); syncTimer = setTimeout(run, 60 * 1000);
}); });
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment