Skip to content

Commit

Permalink
Prevent multiple instances of same background attachment job
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Sep 18, 2019
1 parent 368d5b7 commit 3719724
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/modules/attachment_downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ async function _maybeStartJob() {
const jobs = nextJobs.slice(0, Math.min(needed, nextJobs.length));
for (let i = 0, max = jobs.length; i < max; i += 1) {
const job = jobs[i];
_activeAttachmentDownloadJobs[job.id] = _runJob(job);
const existing = _activeAttachmentDownloadJobs[job.id];
if (existing) {
logger.warn(`_maybeStartJob: Job ${job.id} is already running`);
} else {
_activeAttachmentDownloadJobs[job.id] = _runJob(job);
}
}
}

Expand Down

0 comments on commit 3719724

Please sign in to comment.