diff --git a/src/apps/shared/HttpClient/schema.ts b/src/apps/shared/HttpClient/schema.ts index fad1e5725..6c421e26e 100644 --- a/src/apps/shared/HttpClient/schema.ts +++ b/src/apps/shared/HttpClient/schema.ts @@ -3062,7 +3062,7 @@ export interface components { */ bucket: string; /** - * @description The ID of the file (required when size > 0) + * @description The ID of the file (required when size > 0, must not be provided when size = 0) * @example file12345 */ fileId?: string; @@ -3168,7 +3168,7 @@ export interface components { }; ReplaceFileDto: { /** - * @description File id (required when size > 0) + * @description File id (required when size > 0, must not be provided when size = 0) * @example 651300a2da9b27001f63f384 */ fileId?: string; @@ -3904,7 +3904,7 @@ export interface components { */ bucket: string; /** - * @description The ID of the file (required when size > 0) + * @description The ID of the file (required when size > 0, must not be provided when size = 0) * @example file12345 */ fileId?: string; @@ -5121,6 +5121,8 @@ export interface operations { order?: 'ASC' | 'DESC'; /** @description Filter files updated after this date */ updatedAt?: string; + /** @description The last file uuid of the provided list in the previous call */ + lastId?: string; }; header?: never; path?: never; @@ -8697,7 +8699,7 @@ export interface operations { }; }; responses: { - /** @description Incomplete checkout email sent successfully */ + /** @description Incomplete checkout processed successfully */ 200: { headers: { [name: string]: unknown; diff --git a/src/backend/features/sync/recovery-sync/common/recovery-sync.ts b/src/backend/features/sync/recovery-sync/common/recovery-sync.ts index b5202f922..ea66b9e93 100644 --- a/src/backend/features/sync/recovery-sync/common/recovery-sync.ts +++ b/src/backend/features/sync/recovery-sync/common/recovery-sync.ts @@ -3,10 +3,13 @@ import { sleep } from '@/apps/main/util'; import { FETCH_LIMIT_1000 } from '@/apps/main/remote-sync/store'; import { filesRecoverySync } from '../files/files-recovery-sync'; import { foldersRecoverySync } from '../folders/folders-recovery-sync'; +import { FileUuid } from '@/apps/main/database/entities/DriveFile'; +import { FolderUuid } from '@/apps/main/database/entities/DriveFolder'; async function iterateRecoverySync(ctx: SyncContext, fn: typeof filesRecoverySync | typeof foldersRecoverySync) { let moreItems = true; let offset = 0; + let lastId: FileUuid | FolderUuid | undefined; while (moreItems) { if (ctx.abortController.signal.aborted) { @@ -15,10 +18,11 @@ async function iterateRecoverySync(ctx: SyncContext, fn: typeof filesRecoverySyn } try { - const fileDtos = await fn({ ctx, offset }); + const fileDtos = await fn({ ctx, offset, lastId }); moreItems = fileDtos.length === FETCH_LIMIT_1000; offset += FETCH_LIMIT_1000; + lastId = fileDtos.at(-1)?.uuid; await sleep(30 * 1000); } catch (error) { diff --git a/src/backend/features/sync/recovery-sync/files/files-recovery-sync.ts b/src/backend/features/sync/recovery-sync/files/files-recovery-sync.ts index e2aeb96fc..d95db7a42 100644 --- a/src/backend/features/sync/recovery-sync/files/files-recovery-sync.ts +++ b/src/backend/features/sync/recovery-sync/files/files-recovery-sync.ts @@ -7,19 +7,23 @@ import { SqliteModule } from '@/infra/sqlite/sqlite.module'; import { getItemsToSync } from '../common/get-items-to-sync'; import { getDeletedItems } from '../common/get-deleted-items'; import { GetFilesQuery } from '@/infra/drive-server-wip/services/files.service'; +import { FileUuid } from '@/apps/main/database/entities/DriveFile'; +import { FolderUuid } from '@/apps/main/database/entities/DriveFolder'; type Props = { ctx: SyncContext; offset: number; + lastId: FileUuid | FolderUuid | undefined; }; -export async function filesRecoverySync({ ctx, offset }: Props) { +export async function filesRecoverySync({ ctx, offset, lastId }: Props) { const query: GetFilesQuery = { limit: FETCH_LIMIT_1000, offset, status: 'EXISTS', sort: 'uuid', order: 'ASC', + lastId, }; const { data: remotes } = ctx.workspaceId