Skip to content

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

fix(backend:schedulers): resolve scheduled methods being skipped because of @Timeout decorator overlap

johaven50f4140a7b0b
diff --git a/backend/src/applications/files/services/files-scheduler.service.ts b/backend/src/applications/files/services/files-scheduler.service.ts
index 0a0d1ce6..8d3570ae 100644
--- a/backend/src/applications/files/services/files-scheduler.service.ts
+++ b/backend/src/applications/files/services/files-scheduler.service.ts
@@ -36,7 +36,25 @@ export class FilesScheduler {
private readonly filesContentManager: FilesContentManager
) {}
- @Timeout(30000)
+ @Timeout(30_000)
+ async onStartup(): Promise<void> {
+ try {
+ await this.cleanupInterruptedTasks()
+ await this.clearRecentFiles()
+ } catch (e) {
+ this.logger.error(e)
+ }
+ }
+
+ @Timeout(180_000)
+ async afterStartup(): Promise<void> {
+ try {
+ await this.indexContentFiles()
+ } catch (e) {
+ this.logger.error(e)
+ }
+ }
+
async cleanupInterruptedTasks(): Promise<void> {
this.logger.log(`${this.cleanupInterruptedTasks.name} - START`)
try {
@@ -93,7 +111,6 @@ export class FilesScheduler {
this.logger.log(`${this.cleanupUserTaskFiles.name} - END`)
}
- @Timeout(30000)
@Cron(CronExpression.EVERY_8_HOURS)
async clearRecentFiles(): Promise<void> {
this.logger.log(`${this.clearRecentFiles.name} - START`)
@@ -120,7 +137,6 @@ export class FilesScheduler {
this.logger.log(`${this.clearRecentFiles.name} - ${nbCleared} records cleared - END`)
}
- @Timeout(120000)
@Cron(CronExpression.EVERY_4_HOURS)
async indexContentFiles(): Promise<void> {
// Conditional loading of file content indexing
diff --git a/backend/src/applications/spaces/services/spaces-scheduler.service.ts b/backend/src/applications/spaces/services/spaces-scheduler.service.ts
index c4a975b5..29b774a0 100644
--- a/backend/src/applications/spaces/services/spaces-scheduler.service.ts
+++ b/backend/src/applications/spaces/services/spaces-scheduler.service.ts
@@ -18,7 +18,11 @@ export class SpacesScheduler {
private readonly sharesManager: SharesManager
) {}
- @Timeout(60000)
+ @Timeout(60_000)
+ async onStartup() {
+ await this.updateQuotas()
+ }
+
@Cron(CronExpression.EVERY_HOUR)
async updateQuotas() {
this.logger.log('Update Personal Quotas - START')