mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
Fix bug with multiple cleanup connections being scheduled
This commit is contained in:
parent
28da73e292
commit
aa56ee64aa
1 changed files with 4 additions and 4 deletions
|
|
@ -149,7 +149,8 @@ export class RepoIndexManager {
|
|||
}
|
||||
|
||||
private async scheduleCleanupJobs() {
|
||||
const thresholdDate = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs);
|
||||
const gcGracePeriodMs = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs);
|
||||
const timeoutDate = new Date(Date.now() - this.settings.repoIndexTimeoutMs);
|
||||
|
||||
const reposToCleanup = await this.db.repo.findMany({
|
||||
where: {
|
||||
|
|
@ -158,9 +159,8 @@ export class RepoIndexManager {
|
|||
},
|
||||
OR: [
|
||||
{ indexedAt: null },
|
||||
{ indexedAt: { lt: thresholdDate } },
|
||||
{ indexedAt: { lt: gcGracePeriodMs } },
|
||||
],
|
||||
// Don't schedule if there are active jobs that were created within the threshold date.
|
||||
NOT: {
|
||||
jobs: {
|
||||
some: {
|
||||
|
|
@ -178,7 +178,7 @@ export class RepoIndexManager {
|
|||
},
|
||||
{
|
||||
createdAt: {
|
||||
gt: thresholdDate,
|
||||
gt: timeoutDate,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue