mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Only check the file hash if the x-goog-hash header is present
This commit is contained in:
parent
23ba93aa4c
commit
c3fccec0c2
1 changed files with 7 additions and 4 deletions
|
|
@ -219,10 +219,13 @@ public class AudioSession: ObservableObject {
|
|||
.appendingPathComponent(UUID().uuidString + ".mp3")
|
||||
|
||||
do {
|
||||
let hash = Data(Insecure.MD5.hash(data: data)).base64EncodedString()
|
||||
// if let googleHash = httpResponse.value(forHTTPHeaderField: "x-goog-hash"), googleHash.contains("md5=\(hash)") {
|
||||
// throw BasicError.message(messageText: "Downloaded mp3 file hashes do not match: returned: \(googleHash) v computed: \(hash)")
|
||||
// }
|
||||
if let googleHash = httpResponse.value(forHTTPHeaderField: "x-goog-hash") {
|
||||
let hash = Data(Insecure.MD5.hash(data: data)).base64EncodedString()
|
||||
if !googleHash.contains("md5=\(hash)") {
|
||||
print("Downloaded mp3 file hashes do not match: returned: \(googleHash) v computed: \(hash)")
|
||||
throw BasicError.message(messageText: "Downloaded mp3 file hashes do not match: returned: \(googleHash) v computed: \(hash)")
|
||||
}
|
||||
}
|
||||
|
||||
try data.write(to: tempPath)
|
||||
try FileManager.default.moveItem(at: tempPath, to: audioUrl)
|
||||
|
|
|
|||
Loading…
Reference in a new issue