From 1c5fc3c235e6253f0c530611de44b524164e8ab9 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:16:48 -0600 Subject: [PATCH] Update backup media idle state after resuming download --- .../InstallScreenBackupImportStep.scss | 3 +-- ts/jobs/JobManager.ts | 7 ++++--- ts/services/backups/import.ts | 13 +++++-------- ts/util/backupMediaDownload.ts | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/stylesheets/components/InstallScreenBackupImportStep.scss b/stylesheets/components/InstallScreenBackupImportStep.scss index 98a63f8c8f..2c22706e22 100644 --- a/stylesheets/components/InstallScreenBackupImportStep.scss +++ b/stylesheets/components/InstallScreenBackupImportStep.scss @@ -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; diff --git a/ts/jobs/JobManager.ts b/ts/jobs/JobManager.ts index c6df601735..6b74564760 100644 --- a/ts/jobs/JobManager.ts +++ b/ts/jobs/JobManager.ts @@ -88,9 +88,10 @@ export abstract class JobManager { async start(): Promise { 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(); } diff --git a/ts/services/backups/import.ts b/ts/services/backups/import.ts index 4fdd186b99..9e6717b224 100644 --- a/ts/services/backups/import.ts +++ b/ts/services/backups/import.ts @@ -111,9 +111,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; @@ -362,12 +364,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(); diff --git a/ts/util/backupMediaDownload.ts b/ts/util/backupMediaDownload.ts index a7e352226d..d67fd82b0e 100644 --- a/ts/util/backupMediaDownload.ts +++ b/ts/util/backupMediaDownload.ts @@ -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 { + 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 { await window.storage.put('backupMediaDownloadPaused', true); } export async function resumeBackupMediaDownload(): Promise { - await window.storage.put('backupMediaDownloadPaused', false); + return startBackupMediaDownload(); } export async function resetBackupMediaDownloadItems(): Promise {