Skip to content

Commit 49623b2

Browse files
committed
Merge branch 'release/0.10.3'
2 parents 9f38008 + ff0b89a commit 49623b2

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Unreleased Changes
22

3+
# 0.10.3
4+
Fixes a crash that may occur after updating to 0.10.2.
5+
36
# 0.10.2
47
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]!
58

@@ -35,7 +38,7 @@ This update fixes many issues with the Homebrew check introduced in the last upd
3538
# 0.10
3639
#### New and Improved:
3740
- Added update checking via Homebrew Cask, which should allow for many more updates to be found
38-
- 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
41+
- 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
3942
- Improved messages when no release notes are available
4043
- Interface improvements for macOS Sonoma
4144

Latest.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@
12261226
"@executable_path/../Frameworks",
12271227
"@loader_path/Frameworks",
12281228
);
1229-
MARKETING_VERSION = 0.10.2;
1229+
MARKETING_VERSION = 0.10.3;
12301230
PRODUCT_BUNDLE_IDENTIFIER = "com.max-langer.Latest";
12311231
PRODUCT_NAME = "$(TARGET_NAME)";
12321232
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1260,7 +1260,7 @@
12601260
"@executable_path/../Frameworks",
12611261
"@loader_path/Frameworks",
12621262
);
1263-
MARKETING_VERSION = 0.10.2;
1263+
MARKETING_VERSION = 0.10.3;
12641264
PRODUCT_BUNDLE_IDENTIFIER = "com.max-langer.Latest";
12651265
PRODUCT_NAME = "$(TARGET_NAME)";
12661266
PROVISIONING_PROFILE_SPECIFIER = "";

Latest/Model/Update Repository/UpdateRepository.swift

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,58 @@ class UpdateRepository {
5757
}
5858

5959
/// Entries are still being fetched, add the request to the queue.
60-
queue.async {
61-
if self.entries == nil {
62-
self.pendingRequests.append(checkApp)
60+
queue.async { [weak self] in
61+
guard let self else { return }
62+
63+
if self.pendingRequests != nil {
64+
self.pendingRequests?.append(checkApp)
6365
} else {
6466
checkApp()
6567
}
6668
}
6769
}
6870

6971
/// List of entries stored within the repository.
70-
private var entries: [Entry]?
72+
private var entries: [Entry]!
7173

7274
/// A list of requests being performed while the repository was still fetching data.
73-
private var pendingRequests: [() -> Void] = []
75+
///
76+
/// 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.
77+
private var pendingRequests: [() -> Void]? = []
7478

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

7882
/// Sets the given entries and performs pending requests.
7983
private func finalize() {
80-
queue.async {
84+
queue.async { [weak self] in
85+
guard let self else { return }
86+
guard let pendingRequests else {
87+
fatalError("Finalize must only be called once!")
88+
}
89+
8190
// Perform any pending requests
82-
self.pendingRequests.forEach { request in
91+
pendingRequests.forEach { request in
8392
request()
8493
}
85-
self.pendingRequests.removeAll()
94+
95+
// Mark repository as loaded.
96+
self.pendingRequests = nil
8697
}
8798
}
8899

89100
/// Returns a repository entry for the given name, if available.
90101
private func entry(for bundle: App.Bundle) -> Entry? {
91-
let name = bundle.fileURL.lastPathComponent
92-
93102
// Don't return an entry for unsupported apps
94-
guard let entries, !unsupportedBundleIdentifiers.contains(bundle.bundleIdentifier) else { return nil }
103+
guard !unsupportedBundleIdentifiers.contains(bundle.bundleIdentifier) else { return nil }
95104

96105
// 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.
97106
// However, both app names and bundle identifiers may occur in more than one entry:
98107
// - App Names: Might occur multiple times for similar apps (Telegram.app for Desktop vs. Telegram.app for Mac)
99108
// - Bundle Identifiers: Might occur multiple times for apps in bundles (com.microsoft.word in Word.app and Office bundle)
100109
//
101110
// 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.
111+
let name = bundle.fileURL.lastPathComponent
102112
var possibleEntries = entries.filter { entry in
103113
return entry.names.contains { n in
104114
return n.caseInsensitiveCompare(name) == .orderedSame

Latest/Model/Version/VersionParser.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ enum VersionParser {
2020
// Version Number / Build Number (1.2/1234)
2121
.init(pattern: "(.*)/(.*)", components: [.buildNumber: 2]),
2222

23+
// Build number postfix (1.2 (r1234))
24+
.init(pattern: ".* \\(r(.*)\\)", components: [.buildNumber: 1]),
25+
2326
// Catch all
2427
.init(pattern: ".*", components: [.buildNumber: 0])
2528
]

Tests/VersionParserTest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class VersionParserTest: XCTestCase {
1717
XCTAssertEqual(VersionParser.parse(buildNumber: "IU-1234"), "1234")
1818
XCTAssertEqual(VersionParser.parse(buildNumber: "WS-1234"), "1234")
1919
XCTAssertEqual(VersionParser.parse(buildNumber: "1.2/1234"), "1234")
20+
XCTAssertEqual(VersionParser.parse(buildNumber: "1.2 (r1234)"), "1234")
2021
XCTAssertEqual(VersionParser.parse(buildNumber: "ab-1234"), "ab-1234")
2122
}
2223

0 commit comments

Comments
 (0)