From 91344c12943cae93cd546d245fb8848c51597ae2 Mon Sep 17 00:00:00 2001 From: Davide Date: Wed, 13 Nov 2024 21:46:14 +0100 Subject: [PATCH] Only guard remote fingerprint if local has any (#863) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, it would never import remote profiles w/o a fingerprint. Scenarios (must test in #570): - No local profile → Import - Local profile has no fingerprint → Import - Local profile has fingerprint - Remote profile has no fingerprint → Skip - Remote profile has same fingerprint → Skip - Remote profile has different fingerprint → Import --- .../Sources/CommonLibrary/Business/ProfileManager.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Passepartout/Library/Sources/CommonLibrary/Business/ProfileManager.swift b/Passepartout/Library/Sources/CommonLibrary/Business/ProfileManager.swift index 043443b4..2d2fee50 100644 --- a/Passepartout/Library/Sources/CommonLibrary/Business/ProfileManager.swift +++ b/Passepartout/Library/Sources/CommonLibrary/Business/ProfileManager.swift @@ -440,9 +440,12 @@ private extension ProfileManager { idsToRemove.append(remoteProfile.id) continue } - guard remoteAttributes[remoteProfile.id]?.fingerprint != localAttributes[remoteProfile.id]?.fingerprint else { - pp_log(.App.profiles, .info, "Skip re-importing local profile \(remoteProfile.id)") - continue + if let localFingerprint = localAttributes[remoteProfile.id]?.fingerprint { + guard let remoteFingerprint = remoteAttributes[remoteProfile.id]?.fingerprint, + remoteFingerprint != localFingerprint else { + pp_log(.App.profiles, .info, "Skip re-importing local profile \(remoteProfile.id)") + continue + } } pp_log(.App.profiles, .notice, "Import remote profile \(remoteProfile.id)...") try await save(remoteProfile)