Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/apps/shared/HttpClient/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -8697,7 +8699,7 @@ export interface operations {
};
};
responses: {
/** @description Incomplete checkout email sent successfully */
/** @description Incomplete checkout processed successfully */
200: {
headers: {
[name: string]: unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading