Skip to content

Commit

Permalink
Merge pull request #538 from macadmins/development
Browse files Browse the repository at this point in the history
Fix logging issue when using managed preferences
  • Loading branch information
erikng authored Feb 2, 2024
2 parents bdb3180 + 5912309 commit dc84f0a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ struct MemoizationManager {
struct NetworkFileManager {
private func decodeNudgePreferences(from url: URL) -> NudgePreferences? {
guard let data = try? Data(contentsOf: url) else {
LogManager.error("Failed to load data from URL: \(url)", logger: prefsJSONLog)
if Globals.configProfile.isEmpty {
LogManager.error("Failed to load data from URL: \(url)", logger: prefsJSONLog)
}
return nil
}

Expand Down Expand Up @@ -688,17 +690,17 @@ struct NetworkFileManager {
func getNudgeJSONPreferences() -> NudgePreferences? {
let url = getJSONUrl()

LogManager.debug("JSON url: \(url)", logger: utilsLog)

if CommandLineUtilities().demoModeEnabled() || CommandLineUtilities().unitTestingEnabled() {
return nil
}

if CommandLineUtilities().bundleModeEnabled(), let bundleUrl = Globals.bundle.url(forResource: "com.github.macadmins.Nudge.tester", withExtension: "json") {
LogManager.debug("JSON url: \(bundleUrl)", logger: utilsLog)
return decodeNudgePreferences(from: bundleUrl)
}

if let jsonUrl = URL(string: url) {
LogManager.debug("JSON url: \(url)", logger: utilsLog)
return decodeNudgePreferences(from: jsonUrl)
}

Expand Down

0 comments on commit dc84f0a

Please sign in to comment.