From 0cd93fa007734740d8a4ef2791f33f5edd5c9bb9 Mon Sep 17 00:00:00 2001 From: Harry <109690906+harry-signal@users.noreply.github.com> Date: Fri, 27 Sep 2024 07:55:23 -0700 Subject: [PATCH] Kill StorageServiceManagerImpl.shared --- SignalServiceKit/Environment/AppSetup.swift | 2 +- .../StorageService/StorageServiceManagerImpl.swift | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/SignalServiceKit/Environment/AppSetup.swift b/SignalServiceKit/Environment/AppSetup.swift index a4a1a26e48..da891fa96e 100644 --- a/SignalServiceKit/Environment/AppSetup.swift +++ b/SignalServiceKit/Environment/AppSetup.swift @@ -179,7 +179,7 @@ public class AppSetup { ) let signalService = testDependencies.signalService ?? OWSSignalService() let signalServiceAddressCache = SignalServiceAddressCache() - let storageServiceManager = testDependencies.storageServiceManager ?? StorageServiceManagerImpl.shared + let storageServiceManager = testDependencies.storageServiceManager ?? StorageServiceManagerImpl() let syncManager = testDependencies.syncManager ?? OWSSyncManager(default: ()) let udManager = OWSUDManagerImpl() let versionedProfiles = testDependencies.versionedProfiles ?? VersionedProfilesImpl() diff --git a/SignalServiceKit/StorageService/StorageServiceManagerImpl.swift b/SignalServiceKit/StorageService/StorageServiceManagerImpl.swift index db6c8a08a0..881f9593d6 100644 --- a/SignalServiceKit/StorageService/StorageServiceManagerImpl.swift +++ b/SignalServiceKit/StorageService/StorageServiceManagerImpl.swift @@ -10,11 +10,6 @@ import SwiftProtobuf public class StorageServiceManagerImpl: NSObject, StorageServiceManager { - // TODO: We could convert this into a SSKEnvironment accessor so that we - // can replace it in tests. - @objc - public static let shared = StorageServiceManagerImpl() - private let operationQueue: OperationQueue = { let queue = OperationQueue() queue.maxConcurrentOperationCount = 1 @@ -1131,6 +1126,7 @@ class StorageServiceOperation: OWSOperation { } }.done(on: DispatchQueue.global()) { updatedState in var mutableState = updatedState + let storageServiceManager = self.storageServiceManager self.databaseStorage.write { transaction in // Update the manifest version to reflect the remote version we just restored to mutableState.manifestVersion = manifest.version @@ -1238,7 +1234,7 @@ class StorageServiceOperation: OWSOperation { mutableState.save(clearConsecutiveConflicts: true, transaction: transaction) if backupAfterSuccess { - StorageServiceManagerImpl.shared.backupPendingChanges(authedDevice: self.authedDevice) + storageServiceManager.backupPendingChanges(authedDevice: self.authedDevice) } } self.reportSuccess()