From b78d5925baa798e8ce589bd0b80931116665f51e Mon Sep 17 00:00:00 2001 From: Russel Date: Fri, 17 Sep 2021 00:00:57 +0300 Subject: [PATCH] trigger runtime types update when construction fails --- .../RuntimeRegistryService.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fearless/Common/Services/RuntimeRegistryService/RuntimeRegistryService.swift b/fearless/Common/Services/RuntimeRegistryService/RuntimeRegistryService.swift index 83a6b2774..cc9b62681 100644 --- a/fearless/Common/Services/RuntimeRegistryService/RuntimeRegistryService.swift +++ b/fearless/Common/Services/RuntimeRegistryService/RuntimeRegistryService.swift @@ -257,6 +257,10 @@ final class RuntimeRegistryService { case let .failure(error): logger?.error("Loading runtime snapshot failed: \(error)") + + if shouldSyncFiles { + syncTypeFiles() + } } } @@ -279,7 +283,6 @@ final class RuntimeRegistryService { extension RuntimeRegistryService { private func syncTypeFiles() { guard - let snapshot = snapshot, let baseRemoteUrl = chain.typeDefDefaultFileURL(), let networkRemoteUrl = chain.typeDefNetworkFileURL() else { @@ -352,7 +355,7 @@ extension RuntimeRegistryService { } private func createBaseSaveOperation( - for snapshot: Snapshot, + for snapshot: Snapshot?, dependingOn baseRemote: BaseOperation, networkRemote: BaseOperation, hasher: StorageHasher @@ -363,7 +366,7 @@ extension RuntimeRegistryService { let remoteDataHash = try hasher.hash(data: data) - guard remoteDataHash != snapshot.localBaseHash else { + guard remoteDataHash != snapshot?.localBaseHash else { throw RuntimeRegistryServiceError.noNeedToUpdateTypes } @@ -372,7 +375,7 @@ extension RuntimeRegistryService { } private func createNetworkSaveOperation( - for snapshot: Snapshot, + for snapshot: Snapshot?, dependingOn baseRemote: BaseOperation, networkRemote: BaseOperation, hasher: StorageHasher @@ -383,7 +386,7 @@ extension RuntimeRegistryService { let remoteDataHash = try hasher.hash(data: data) - guard remoteDataHash != snapshot.localNetworkHash else { + guard remoteDataHash != snapshot?.localNetworkHash else { throw RuntimeRegistryServiceError.noNeedToUpdateTypes }