Backup import cancel UI

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-09-11 17:10:02 -05:00 committed by GitHub
parent 7700953777
commit d2c02b1246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 183 additions and 25 deletions

View file

@ -1175,6 +1175,7 @@ export type GetBackupStreamOptionsType = Readonly<{
headers: Record<string, string>;
downloadOffset: number;
onProgress: (currentBytes: number, totalBytes: number) => void;
abortSignal?: AbortSignal;
}>;
export const getBackupInfoResponseSchema = z.object({
@ -2815,6 +2816,7 @@ export function initialize({
backupName,
downloadOffset,
onProgress,
abortSignal,
}: GetBackupStreamOptionsType): Promise<Readable> {
return _getAttachment({
cdnPath: `/backups/${encodeURIComponent(backupDir)}/${encodeURIComponent(backupName)}`,
@ -2824,6 +2826,7 @@ export function initialize({
options: {
downloadOffset,
onProgress,
abortSignal,
},
});
}
@ -3550,6 +3553,7 @@ export function initialize({
timeout?: number;
downloadOffset?: number;
onProgress?: (currentBytes: number, totalBytes: number) => void;
abortSignal?: AbortSignal;
};
}): Promise<Readable> {
const abortController = new AbortController();
@ -3561,6 +3565,8 @@ export function initialize({
abortController.abort();
};
options?.abortSignal?.addEventListener('abort', cancelRequest);
registerInflightRequest(cancelRequest);
let totalBytes = 0;