Skip to content

Commit df26edf

Browse files
fix: harden CLI download with HTTP status check
1 parent a2be207 commit df26edf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tools/gins-rime-cli/Sources/GinsRime/Commands/Update.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ struct Update: AsyncParsableCommand {
138138
private func updateModel() async throws {
139139
let url = URL(string: "\(GinsSettings.workerBase)/\(GinsSettings.modelR2Key)")!
140140
let dest = RimePaths.user.appendingPathComponent(GinsSettings.modelLocalName)
141-
let (tmp, _) = try await URLSession.shared.download(from: url)
141+
let (tmp, response) = try await URLSession.shared.download(from: url)
142+
143+
guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else {
144+
throw GinsRimeError.downloadFailed(url.absoluteString)
145+
}
146+
142147
if FileManager.default.fileExists(atPath: dest.path) {
143148
try FileManager.default.removeItem(at: dest)
144149
}

0 commit comments

Comments
 (0)