Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Xcodes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
CAFE4AB425B7D3AF0064FE51 /* AdvancedPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4AB325B7D3AF0064FE51 /* AdvancedPreferencePane.swift */; };
CAFE4ABC25B7D54B0064FE51 /* UpdatesPreferencePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFE4ABB25B7D54B0064FE51 /* UpdatesPreferencePane.swift */; };
CAFFFED8259CDA5000903F81 /* XcodeListViewRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFFFED7259CDA5000903F81 /* XcodeListViewRow.swift */; };
E689540325BE8C64000EBCEA /* DockProgress in Frameworks */ = {isa = PBXBuildFile; productRef = E689540225BE8C64000EBCEA /* DockProgress */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -276,6 +277,7 @@
CAFE4AA325B7CF960064FE51 /* Preferences in Frameworks */,
CABFA9E42592F08E00380FEE /* Version in Frameworks */,
CABFA9FD2592F13300380FEE /* LegibleError in Frameworks */,
E689540325BE8C64000EBCEA /* DockProgress in Frameworks */,
CA9FF86D25951C6E00E47BAF /* XCModel in Frameworks */,
CABFA9F82592F0F900380FEE /* KeychainAccess in Frameworks */,
CAA858CD25A3D8BC00ACF8C0 /* ErrorHandling in Frameworks */,
Expand Down Expand Up @@ -591,6 +593,7 @@
CAA858CC25A3D8BC00ACF8C0 /* ErrorHandling */,
CAFE4A9925B7C7A30064FE51 /* Sparkle */,
CAFE4AA225B7CF960064FE51 /* Preferences */,
E689540225BE8C64000EBCEA /* DockProgress */,
);
productName = XcodesMac;
productReference = CAD2E79E2449574E00113D76 /* Xcodes.app */;
Expand Down Expand Up @@ -659,6 +662,7 @@
CAC28186259EE27200B8AB0B /* XCRemoteSwiftPackageReference "CombineExpectations" */,
CAFE4A9825B7C7A30064FE51 /* XCRemoteSwiftPackageReference "Sparkle" */,
CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */,
E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */,
);
productRefGroup = CAD2E79F2449574E00113D76 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1341,6 +1345,14 @@
minimumVersion = 2.2.0;
};
};
E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/DockProgress";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 3.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -1398,6 +1410,11 @@
package = CAFE4AA125B7CF960064FE51 /* XCRemoteSwiftPackageReference "Preferences" */;
productName = Preferences;
};
E689540225BE8C64000EBCEA /* DockProgress */ = {
isa = XCSwiftPackageProductDependency;
package = E689540125BE8C64000EBCEA /* XCRemoteSwiftPackageReference "DockProgress" */;
productName = DockProgress;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = CAD2E7962449574E00113D76 /* Project object */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Xcodes/Backend/AppState+Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AppleAPI
import Version
import LegibleError
import os.log
import DockProgress

/// Downloads and installs Xcodes
extension AppState {
Expand Down Expand Up @@ -119,6 +120,7 @@ extension AppState {
cookies
)
progressChanged(progress)
updateDockIcon(withProgress: progress)
return publisher
.map { _ in destination.url }
.eraseToAnyPublisher()
Expand All @@ -128,11 +130,12 @@ extension AppState {
let resumeDataPath = Path.xcodesApplicationSupport/"Xcode-\(availableXcode.version).resumedata"
let persistedResumeData = Current.files.contents(atPath: resumeDataPath.string)

return attemptResumableTask(maximumRetryCount: 3) { resumeData -> AnyPublisher<URL, Error> in
return attemptResumableTask(maximumRetryCount: 3) { [weak self] resumeData -> AnyPublisher<URL, Error> in
let (progress, publisher) = Current.network.downloadTask(with: availableXcode.url,
to: destination.url,
resumingWith: resumeData ?? persistedResumeData)
progressChanged(progress)
self?.updateDockIcon(withProgress: progress)
return publisher
.map { $0.saveLocation }
.eraseToAnyPublisher()
Expand All @@ -142,6 +145,11 @@ extension AppState {
})
.eraseToAnyPublisher()
}

private func updateDockIcon(withProgress progress: Progress) {
DockProgress.style = .bar
DockProgress.progressInstance = progress
}

public func installArchivedXcode(_ availableXcode: AvailableXcode, at archiveURL: URL) -> AnyPublisher<InstalledXcode, Error> {
do {
Expand Down
4 changes: 4 additions & 0 deletions Xcodes/Backend/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import LegibleError
import KeychainAccess
import Path
import Version
import DockProgress

class AppState: ObservableObject {
private let client = AppleAPI.Client()
Expand Down Expand Up @@ -298,6 +299,9 @@ class AppState: ObservableObject {

// Cancel the publisher
installationPublishers[id] = nil

// Remove dock icon progress indicator
DockProgress.progress = 1 // Only way to completely remove overlay with DockProgress is setting progress to complete

// If the download is cancelled by the user, clean up the download files that aria2 creates.
// This isn't done as part of the publisher with handleEvents(receiveCancel:) because it shouldn't happen when e.g. the app quits.
Expand Down
2 changes: 1 addition & 1 deletion Xcodes/Frontend/XcodeList/InstallationStepView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct InstallationStepView: View {
controlSize: .small,
style: .spinning
)
.help("Dowloading: \(Int((progress.fractionCompleted * 100)))% complete")
.help("Downloading: \(Int((progress.fractionCompleted * 100)))% complete")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

case .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing:
ProgressView()
.scaleEffect(0.5)
Expand Down
15 changes: 15 additions & 0 deletions Xcodes/Resources/Licenses.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ For more information, please refer to &lt;<http://unlicense.org/>&gt;\
otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\
\

\fs34 DockProgress\
\

\fs26 MIT License\
\
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)\
\
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\
\
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\
\
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\
\
\

\fs34 KeychainAccess\
\

Expand Down