Skip to content

Commit bca1b5b

Browse files
committed
Fix offline mode check
1 parent 9461057 commit bca1b5b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/Hub/HubApi.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,16 @@ public extension HubApi {
576576
.appendingPathComponent("huggingface")
577577
.appendingPathComponent("download")
578578

579-
if await NetworkMonitor.shared.state.shouldUseOfflineMode() || useOfflineMode == true {
579+
let shouldUseOfflineMode: Bool
580+
if useOfflineMode == true {
581+
shouldUseOfflineMode = true
582+
} else if useOfflineMode == nil {
583+
shouldUseOfflineMode = await NetworkMonitor.shared.state.shouldUseOfflineMode()
584+
} else {
585+
shouldUseOfflineMode = false
586+
}
587+
588+
if shouldUseOfflineMode {
580589
if !FileManager.default.fileExists(atPath: repoDestination.path) {
581590
throw EnvironmentError.offlineModeError(String(localized: "Repository not available locally"))
582591
}

0 commit comments

Comments
 (0)