diff --git a/Sources/Hub/HubApi.swift b/Sources/Hub/HubApi.swift index e89dab0..06d009d 100644 --- a/Sources/Hub/HubApi.swift +++ b/Sources/Hub/HubApi.swift @@ -576,7 +576,16 @@ public extension HubApi { .appendingPathComponent("huggingface") .appendingPathComponent("download") - if await NetworkMonitor.shared.state.shouldUseOfflineMode() || useOfflineMode == true { + let shouldUseOfflineMode: Bool + if useOfflineMode == true { + shouldUseOfflineMode = true + } else if useOfflineMode == nil { + shouldUseOfflineMode = await NetworkMonitor.shared.state.shouldUseOfflineMode() + } else { + shouldUseOfflineMode = false + } + + if shouldUseOfflineMode { if !FileManager.default.fileExists(atPath: repoDestination.path) { throw EnvironmentError.offlineModeError(String(localized: "Repository not available locally")) }