diff --git a/Whisky.xcodeproj/project.pbxproj b/Whisky.xcodeproj/project.pbxproj index 2eb4ef159..da98e75e5 100644 --- a/Whisky.xcodeproj/project.pbxproj +++ b/Whisky.xcodeproj/project.pbxproj @@ -49,7 +49,6 @@ 6EDF9AB62A9A6D8C006CAA7E /* BottleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDF9AB52A9A6D8C006CAA7E /* BottleData.swift */; }; 6EDF9AB72A9A6E50006CAA7E /* WhiskyKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EDF9AA92A9A6CA9006CAA7E /* WhiskyKit.framework */; }; 6EDF9ABD2A9A6E83006CAA7E /* SemanticVersion in Frameworks */ = {isa = PBXBuildFile; productRef = 6EDF9ABC2A9A6E83006CAA7E /* SemanticVersion */; }; - 6EDF9ABE2A9A6F3D006CAA7E /* GPTKDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EF557952A40B8D1001A4F09 /* GPTKDownloader.swift */; }; 6EDF9ABF2A9A6F3D006CAA7E /* GPTKInstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E0822862A39D73800195094 /* GPTKInstaller.swift */; }; 6EDF9AC32A9A6F46006CAA7E /* Tar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E0822852A39D73800195094 /* Tar.swift */; }; 6EF557982A410599001A4F09 /* SetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EF557972A410599001A4F09 /* SetupView.swift */; }; @@ -202,7 +201,6 @@ 6EA2D48429DF130F00C84668 /* ProgramSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgramSettings.swift; sourceTree = ""; }; 6EDF9AA92A9A6CA9006CAA7E /* WhiskyKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WhiskyKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6EDF9AB52A9A6D8C006CAA7E /* BottleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottleData.swift; sourceTree = ""; }; - 6EF557952A40B8D1001A4F09 /* GPTKDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GPTKDownloader.swift; sourceTree = ""; }; 6EF557972A410599001A4F09 /* SetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupView.swift; sourceTree = ""; }; 6EFDF6432AAD65F500EF622F /* BitmapInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BitmapInfo.swift; sourceTree = ""; }; 6EFDF64A2AAE2DA800EF622F /* WhiskyThumbnail.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WhiskyThumbnail.appex; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -434,7 +432,6 @@ 6EDF9AC42A9A6FB5006CAA7E /* GPTK */ = { isa = PBXGroup; children = ( - 6EF557952A40B8D1001A4F09 /* GPTKDownloader.swift */, 6E0822862A39D73800195094 /* GPTKInstaller.swift */, ); path = GPTK; @@ -732,7 +729,6 @@ buildActionMask = 2147483647; files = ( 6E309A1E2AB3A12300D0167E /* BottleSettings.swift in Sources */, - 6EDF9ABE2A9A6F3D006CAA7E /* GPTKDownloader.swift in Sources */, 6EFDF6632AAE2E1700EF622F /* DataExtensions.swift in Sources */, 6EDF9ABF2A9A6F3D006CAA7E /* GPTKInstaller.swift in Sources */, 6E309A232AB3A80400D0167E /* ProgramSettings.swift in Sources */, diff --git a/Whisky/Views/Setup Views/GPTKDownloadView.swift b/Whisky/Views/Setup Views/GPTKDownloadView.swift index fdca49fd8..0654cd97f 100644 --- a/Whisky/Views/Setup Views/GPTKDownloadView.swift +++ b/Whisky/Views/Setup Views/GPTKDownloadView.swift @@ -65,8 +65,7 @@ struct GPTKDownloadView: View { .frame(width: 400, height: 200) .onAppear { Task { - if let downloadInfo = await GPTKDownloader.getLatestGPTKURL(), - let url = downloadInfo.directURL { + if let url: URL = URL(string: "https://data.getwhisky.app/Libraries.zip") { downloadTask = URLSession.shared.downloadTask(with: url) { url, _, _ in if let url = url { tarLocation = url @@ -81,16 +80,14 @@ struct GPTKDownloadView: View { if completedBytes > 0 { downloadSpeed = Double(completedBytes) / elapsedTime } - fractionProgress = Double(task.countOfBytesReceived) / Double(totalBytes) + totalBytes = task.countOfBytesExpectedToReceive completedBytes = task.countOfBytesReceived + fractionProgress = Double(completedBytes) / Double(totalBytes) } } } startTime = Date() downloadTask?.resume() - await MainActor.run { - totalBytes = Int64(downloadInfo.totalByteCount) - } } } } diff --git a/WhiskyKit/GPTK/GPTKDownloader.swift b/WhiskyKit/GPTK/GPTKDownloader.swift deleted file mode 100644 index c571996ca..000000000 --- a/WhiskyKit/GPTK/GPTKDownloader.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// GPTKDownloader.swift -// WhiskyKit -// -// This file is part of Whisky. -// -// Whisky is free software: you can redistribute it and/or modify it under the terms -// of the GNU General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Whisky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along with Whisky. -// If not, see https://www.gnu.org/licenses/. -// - -import Foundation - -public class GPTKDownloader { - public static func getLatestGPTKURL() async -> DownloadInfo? { - let githubURL = "https://api.github.com/repos/IsaacMarovitz/WhiskyBuilder/actions/artifacts" - if let artifactsURL = URL(string: githubURL) { - return await withCheckedContinuation { continuation in - URLSession.shared.dataTask(with: URLRequest(url: artifactsURL)) { data, _, error in - do { - if error == nil, let data = data { - let decoder = JSONDecoder() - decoder.keyDecodingStrategy = .convertFromSnakeCase - let artifacts: Artifacts = try decoder.decode(Artifacts.self, from: data) - // We gotta turn the URL into a nightly.link URL - if let latest = artifacts.artifacts.first { - var url = latest.url - url.replace("https://api.github.com/repos/", with: "https://nightly.link/") - let selection = "actions/" - if let range = url.range(of: selection) { - url = String(url[..