Skip to content

Commit

Permalink
trigger runtime types update when construction fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ERussel committed Sep 16, 2021
1 parent 4d374bd commit b78d592
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ final class RuntimeRegistryService {

case let .failure(error):
logger?.error("Loading runtime snapshot failed: \(error)")

if shouldSyncFiles {
syncTypeFiles()
}
}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -352,7 +355,7 @@ extension RuntimeRegistryService {
}

private func createBaseSaveOperation(
for snapshot: Snapshot,
for snapshot: Snapshot?,
dependingOn baseRemote: BaseOperation<Data>,
networkRemote: BaseOperation<Data>,
hasher: StorageHasher
Expand All @@ -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
}

Expand All @@ -372,7 +375,7 @@ extension RuntimeRegistryService {
}

private func createNetworkSaveOperation(
for snapshot: Snapshot,
for snapshot: Snapshot?,
dependingOn baseRemote: BaseOperation<Data>,
networkRemote: BaseOperation<Data>,
hasher: StorageHasher
Expand All @@ -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
}

Expand Down

0 comments on commit b78d592

Please sign in to comment.