Backup import cancel UI
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
7700953777
commit
d2c02b1246
9 changed files with 183 additions and 25 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue