Resumable backup import

This commit is contained in:
Fedor Indutny
2024-08-27 17:00:41 -04:00
committed by GitHub
parent 3d8aaf0a5a
commit 8ef149e3a8
17 changed files with 498 additions and 33 deletions

View File

@@ -14,6 +14,11 @@ import type {
import type { BackupCredentials } from './credentials';
import { uploadFile } from '../../util/uploadAttachment';
export type DownloadOptionsType = Readonly<{
downloadOffset: number;
onProgress: (currentBytes: number, totalBytes: number) => void;
}>;
export class BackupAPI {
private cachedBackupInfo: GetBackupInfoResponseType | undefined;
constructor(private credentials: BackupCredentials) {}
@@ -67,7 +72,10 @@ export class BackupAPI {
});
}
public async download(): Promise<Readable> {
public async download({
downloadOffset,
onProgress,
}: DownloadOptionsType): Promise<Readable> {
const { cdn, backupDir, backupName } = await this.getInfo();
const { headers } = await this.credentials.getCDNReadCredentials(cdn);
@@ -76,6 +84,8 @@ export class BackupAPI {
backupDir,
backupName,
headers,
downloadOffset,
onProgress,
});
}