Skip to content

Commit

Permalink
Merge branch 'release/0.10.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mangerlahn committed Dec 19, 2023
2 parents 9f38008 + ff0b89a commit 49623b2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased Changes

# 0.10.3
Fixes a crash that may occur after updating to 0.10.2.

# 0.10.2
This update fixes more issues with the Homebrew check introduced in a recent update. Thank you for your continued reports, [please keep them coming][1]!

Expand Down Expand Up @@ -35,7 +38,7 @@ This update fixes many issues with the Homebrew check introduced in the last upd
# 0.10
#### New and Improved:
- Added update checking via Homebrew Cask, which should allow for many more updates to be found
- The app list is now sorted by recently updated apps. Sort by app name can be restored via the main menu: View > Sort By > Name
- The app list is now sorted by recently updated apps. Sort by app name can be restored via the main menu: View \> Sort By \> Name
- Improved messages when no release notes are available
- Interface improvements for macOS Sonoma

Expand Down
4 changes: 2 additions & 2 deletions Latest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.10.2;
MARKETING_VERSION = 0.10.3;
PRODUCT_BUNDLE_IDENTIFIER = "com.max-langer.Latest";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1260,7 +1260,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.10.2;
MARKETING_VERSION = 0.10.3;
PRODUCT_BUNDLE_IDENTIFIER = "com.max-langer.Latest";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
32 changes: 21 additions & 11 deletions Latest/Model/Update Repository/UpdateRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,58 @@ class UpdateRepository {
}

/// Entries are still being fetched, add the request to the queue.
queue.async {
if self.entries == nil {
self.pendingRequests.append(checkApp)
queue.async { [weak self] in
guard let self else { return }

if self.pendingRequests != nil {
self.pendingRequests?.append(checkApp)
} else {
checkApp()
}
}
}

/// List of entries stored within the repository.
private var entries: [Entry]?
private var entries: [Entry]!

/// A list of requests being performed while the repository was still fetching data.
private var pendingRequests: [() -> Void] = []
///
/// It also acts as a flag for whether initialization finished. The array is initialized when the repository is created. It will be set to nil once `finalize()` is being called.
private var pendingRequests: [() -> Void]? = []

/// A set of bundle identifiers for which update checking is currently not supported.
private var unsupportedBundleIdentifiers: Set<String>!

/// Sets the given entries and performs pending requests.
private func finalize() {
queue.async {
queue.async { [weak self] in
guard let self else { return }
guard let pendingRequests else {
fatalError("Finalize must only be called once!")
}

// Perform any pending requests
self.pendingRequests.forEach { request in
pendingRequests.forEach { request in
request()
}
self.pendingRequests.removeAll()

// Mark repository as loaded.
self.pendingRequests = nil
}
}

/// Returns a repository entry for the given name, if available.
private func entry(for bundle: App.Bundle) -> Entry? {
let name = bundle.fileURL.lastPathComponent

// Don't return an entry for unsupported apps
guard let entries, !unsupportedBundleIdentifiers.contains(bundle.bundleIdentifier) else { return nil }
guard !unsupportedBundleIdentifiers.contains(bundle.bundleIdentifier) else { return nil }

// Finding the correct entry is not trivial as there is no bundle identifier stored in an entry. We have a list of app names (could be ambiguous) and a list of bundle identifier guesses.
// However, both app names and bundle identifiers may occur in more than one entry:
// - App Names: Might occur multiple times for similar apps (Telegram.app for Desktop vs. Telegram.app for Mac)
// - Bundle Identifiers: Might occur multiple times for apps in bundles (com.microsoft.word in Word.app and Office bundle)
//
// Strategy: Find all entries that point to the given app name. If only one entry comes up, return that. Otherwise, try to match bundle identifiers to narrow it down.
let name = bundle.fileURL.lastPathComponent
var possibleEntries = entries.filter { entry in
return entry.names.contains { n in
return n.caseInsensitiveCompare(name) == .orderedSame
Expand Down
3 changes: 3 additions & 0 deletions Latest/Model/Version/VersionParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ enum VersionParser {
// Version Number / Build Number (1.2/1234)
.init(pattern: "(.*)/(.*)", components: [.buildNumber: 2]),

// Build number postfix (1.2 (r1234))
.init(pattern: ".* \\(r(.*)\\)", components: [.buildNumber: 1]),

// Catch all
.init(pattern: ".*", components: [.buildNumber: 0])
]
Expand Down
1 change: 1 addition & 0 deletions Tests/VersionParserTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class VersionParserTest: XCTestCase {
XCTAssertEqual(VersionParser.parse(buildNumber: "IU-1234"), "1234")
XCTAssertEqual(VersionParser.parse(buildNumber: "WS-1234"), "1234")
XCTAssertEqual(VersionParser.parse(buildNumber: "1.2/1234"), "1234")
XCTAssertEqual(VersionParser.parse(buildNumber: "1.2 (r1234)"), "1234")
XCTAssertEqual(VersionParser.parse(buildNumber: "ab-1234"), "ab-1234")
}

Expand Down

0 comments on commit 49623b2

Please sign in to comment.