fix: ensure lock stays on
This commit is contained in:
@@ -74,11 +74,9 @@ export class LibraryService extends EventEmitter {
|
||||
const { watch, scan } = config.library;
|
||||
this.watchLibraries = false;
|
||||
if (watch.enabled) {
|
||||
this.databaseRepository.withTryLock(DatabaseLock.LibraryWatch, async () => {
|
||||
// This ensures that library watching only occurs in one microservice
|
||||
// TODO: we could make the lock be per-library instead of global
|
||||
this.watchLibraries = true;
|
||||
});
|
||||
// This ensures that library watching only occurs in one microservice
|
||||
// TODO: we could make the lock be per-library instead of global
|
||||
this.watchLibraries = await this.databaseRepository.tryLock(DatabaseLock.LibraryWatch);
|
||||
}
|
||||
this.jobRepository.addCronJob(
|
||||
'libraryScan',
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface IDatabaseRepository {
|
||||
shouldReindex(name: VectorIndex): Promise<boolean>;
|
||||
runMigrations(options?: { transaction?: 'all' | 'none' | 'each' }): Promise<void>;
|
||||
withLock<R>(lock: DatabaseLock, callback: () => Promise<R>): Promise<R>;
|
||||
withTryLock<R>(lock: DatabaseLock, callback: () => Promise<R>): Promise<R>;
|
||||
tryLock(lock: DatabaseLock): Promise<boolean>;
|
||||
isBusy(lock: DatabaseLock): boolean;
|
||||
wait(lock: DatabaseLock): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user