Consolidate update+reader & remove some dead code

This commit is contained in:
2024-11-22 21:01:01 +11:00
parent cc703ad0c5
commit be51934334
7 changed files with 108 additions and 170 deletions

View File

@ -6,28 +6,6 @@
import Foundation
public struct ApkIndexDownloader {
@available(*, deprecated, message: "This is stinky, use ApkIndexDownloader.fetch instead")
internal func downloadFile(remote remoteURL: URL, destination destLocalURL: URL) {
let sem = DispatchSemaphore.init(value: 0)
let downloadTask = URLSession.shared.downloadTask(with: remoteURL) { url, response, error in
if let localURL = url {
do {
// Replace existing APKINDEX.tar.gz files
if FileManager.default.fileExists(atPath: destLocalURL.path()) {
try FileManager.default.removeItem(at: destLocalURL)
}
// Move temporary to the new location
try FileManager.default.moveItem(at: localURL, to: destLocalURL)
} catch {
print("Download error: \(error.localizedDescription)")
}
}
sem.signal()
}
downloadTask.resume()
sem.wait()
}
public static func fetch(repository: ApkIndexRepository) async throws(FetchError) -> URL {
let localDestinationURL = URL(filePath: repository.localName)