Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend:files): ensure content indexing scheduling has no parallel executions

johaven0bef5a6799e7
diff --git a/.gitignore b/.gitignore
index 0b077ab4..39fe4586 100755
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,5 @@ frontend/tmp
frontend/out-tsc
frontend/bazel-out
/frontend/src/assets/pdfjs/
-circular-dependencies.png
\ No newline at end of file
+circular-dependencies.png!
+backend/src/applications/files/assets/ocr-languages/*.traineddata
\ No newline at end of file
diff --git a/backend/src/applications/files/assets/ocr-languages/.gitkeep b/backend/src/applications/files/assets/ocr-languages/.gitkeep
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/backend/src/applications/files/assets/ocr-languages/.gitkeep
@@ -0,0 +1 @@
+
diff --git a/backend/src/applications/files/services/files-scheduler.service.ts b/backend/src/applications/files/services/files-scheduler.service.ts
index 6ab0b556..80f46428 100644
--- a/backend/src/applications/files/services/files-scheduler.service.ts
+++ b/backend/src/applications/files/services/files-scheduler.service.ts
@@ -23,6 +23,7 @@ import { FilesTasksManager } from './files-tasks-manager.service'
@Injectable()
export class FilesScheduler {
private readonly logger = new Logger(FilesScheduler.name)
+ private isIndexContentFilesRunning = false
constructor(
@Inject(DB_TOKEN_PROVIDER) private readonly db: DBSchema,
@@ -134,10 +135,19 @@ export class FilesScheduler {
@Cron(CronExpression.EVERY_4_HOURS)
async indexContentFiles(): Promise<void> {
// Conditional loading of file content indexing
- if (!configuration.applications.files.contentIndexing) return
+ if (!configuration.applications.files.contentIndexing.enabled) return
+ if (this.isIndexContentFilesRunning) {
+ this.logger.warn({ tag: this.indexContentFiles.name, msg: `SKIP (already running)` })
+ return
+ }
+ this.isIndexContentFilesRunning = true
this.logger.log({ tag: this.indexContentFiles.name, msg: `START` })
- await this.filesContentManager.parseAndIndexAllFiles()
- this.logger.log({ tag: this.indexContentFiles.name, msg: `END` })
+ try {
+ await this.filesContentManager.parseAndIndexAllFiles()
+ this.logger.log({ tag: this.indexContentFiles.name, msg: `END` })
+ } finally {
+ this.isIndexContentFilesRunning = false
+ }
}
@Cron(CronExpression.EVERY_DAY_AT_4AM)