Update backup media idle state after resuming download

This commit is contained in:
trevor-signal 2024-11-13 12:30:35 -05:00 committed by GitHub
parent 0295cb3963
commit ca20d07f75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 14 deletions

View file

@ -17,7 +17,7 @@
flex-direction: column;
justify-content: center;
text-align: center;
margin-top: 64px;
margin-top: 72px;
flex: 1;
}
@ -72,7 +72,6 @@
.InstallScreenBackupImportStep__footer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 36px;
min-height: 94px;

View file

@ -88,9 +88,10 @@ export abstract class JobManager<CoreJobType> {
async start(): Promise<void> {
log.info(`${this.logPrefix}: starting`);
this.enabled = true;
await this.params.markAllJobsInactive();
if (!this.enabled) {
this.enabled = true;
await this.params.markAllJobsInactive();
}
await this.maybeStartJobs();
this.tick();
}

View file

@ -109,9 +109,11 @@ import type { RawBodyRange } from '../../types/BodyRange';
import { fromAdminKeyBytes } from '../../util/callLinks';
import { getRoomIdFromRootKey } from '../../util/callLinksRingrtc';
import { loadAllAndReinitializeRedux } from '../allLoaders';
import { resetBackupMediaDownloadProgress } from '../../util/backupMediaDownload';
import {
resetBackupMediaDownloadProgress,
startBackupMediaDownload,
} from '../../util/backupMediaDownload';
import { getEnvironment, isTestEnvironment } from '../../environment';
import { drop } from '../../util/drop';
import { hasAttachmentDownloads } from '../../util/hasAttachmentDownloads';
const MAX_CONCURRENCY = 10;
@ -353,12 +355,7 @@ export class BackupImportStream extends Writable {
this.backupType !== BackupType.TestOnlyPlaintext &&
!isTestEnvironment(getEnvironment())
) {
await AttachmentDownloadManager.start();
drop(
AttachmentDownloadManager.waitForIdle(async () => {
await window.storage.put('backupMediaDownloadIdle', true);
})
);
await startBackupMediaDownload();
}
done();

View file

@ -1,14 +1,28 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { AttachmentDownloadManager } from '../jobs/AttachmentDownloadManager';
import { DataWriter } from '../sql/Client';
import { drop } from './drop';
export async function startBackupMediaDownload(): Promise<void> {
await window.storage.put('backupMediaDownloadPaused', false);
await window.storage.put('backupMediaDownloadIdle', false);
await AttachmentDownloadManager.start();
drop(
AttachmentDownloadManager.waitForIdle(async () => {
await window.storage.put('backupMediaDownloadIdle', true);
})
);
}
export async function pauseBackupMediaDownload(): Promise<void> {
await window.storage.put('backupMediaDownloadPaused', true);
}
export async function resumeBackupMediaDownload(): Promise<void> {
await window.storage.put('backupMediaDownloadPaused', false);
return startBackupMediaDownload();
}
export async function resetBackupMediaDownloadItems(): Promise<void> {