Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
highball library lists every GOG game the account owns, not only installed ones. The CLI asked GOG nothing and looked up installed ids alone, so a frontend saw no GOG game to install (highball#432, udance4ever). It now reads the owned list the app saves after each GOG refresh (library-cache.json, gabeperez's #606), then adds installed games that list lacks, as the app does. (#664)
Gauthier Piarrette8b90db915673
diff --git a/Sources/HighballKit/GOGLibrary.swift b/Sources/HighballKit/GOGLibrary.swiftindex eb50a07..5024e3e 100644--- a/Sources/HighballKit/GOGLibrary.swift+++ b/Sources/HighballKit/GOGLibrary.swift@@ -130,6 +130,17 @@ extension GOGStore {}return (try? Self.fetch(Self.releaseRequest(id, certificate: nil, token: nil))).flatMap { Self.parseRelease(id: id, data: $0) }}++ /// The owned list as the app last saw it, from library-cache.json in Highball's home (the app+ /// writes it after each GOG refresh). The CLI lists the library without asking GOG, and read only+ /// installed games until now, so `highball library` left out every GOG game not installed+ /// (highball#432). Empty when the app never saved one.+ public static func lastSeenOwnedGames(home: URL) -> [Game] {+ struct Snapshot: Decodable { var gogGames: [Game]? }+ guard let data = try? Data(contentsOf: home.appending(path: "library-cache.json")),+ let snapshot = try? JSONDecoder().decode(Snapshot.self, from: data) else { return [] }+ return snapshot.gogGames ?? []+ }}// MARK: Installed games, read from diskdiff --git a/Sources/highball/main.swift b/Sources/highball/main.swiftindex 174000d..be757f1 100644--- a/Sources/highball/main.swift+++ b/Sources/highball/main.swift@@ -919,7 +919,13 @@ func currentLibrary(paths: HighballPaths, epic: Bool) -> [LibraryItem] {// programs added by hand its tiles stand for, so both list the same ids.let gogStore = GOGStore(paths: paths)let gogInstalled = Dictionary(bottles.map { ($0.name, GOGStore.installedGames(driveC: $0.driveC)) }, uniquingKeysWith: { a, _ in a })- let gogGames = epic ? Set(gogInstalled.values.joined().map(\.id)).sorted().compactMap { gogStore.game($0) } : []+ // The owned list the app saved, then installed games it doesn't hold (an offline installer's).+ var gogGames: [GOGStore.Game] = []+ if epic {+ let owned = gogStore.isAuthenticated ? GOGStore.lastSeenOwnedGames(home: paths.home) : []+ let installedOnly = Set(gogInstalled.values.joined().map(\.id)).subtracting(owned.map(\.id))+ gogGames = owned + installedOnly.sorted().compactMap { gogStore.game($0) }+ }return LibraryIndex.build(bottles: bottles, steamByBottle: steam, steamOwnedByBottle: owned,macInstalled: MacSteam.installedGames(), epicOwned: epicOwned, epicInstalls: epicInstalls,gogGames: gogGames, gogInstalledByBottle: gogInstalled,diff --git a/Tests/HighballKitTests/GOGStoreTests.swift b/Tests/HighballKitTests/GOGStoreTests.swiftindex c12b419..a299d61 100644--- a/Tests/HighballKitTests/GOGStoreTests.swift+++ b/Tests/HighballKitTests/GOGStoreTests.swift@@ -927,4 +927,23 @@ final class GOGStoreTests: XCTestCase {XCTAssertEqual(try running.readToEnd(), Data("comet 0.4.0".utf8))XCTAssertEqual(try Data(contentsOf: binary), Data("comet 0.4.1".utf8))}++ /// highball#432: `highball library` listed only installed GOG games. The CLI now reads the+ /// owned list the app saved in library-cache.json, beside Epic's lists it ignores here.+ func testTheCLIReadsTheOwnedListTheAppSaved() throws {+ let home = FileManager.default.temporaryDirectory.appending(path: "hb-gogcache-\(UUID().uuidString)", directoryHint: .isDirectory)+ try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)+ defer { try? FileManager.default.removeItem(at: home) }+ XCTAssertEqual(GOGStore.lastSeenOwnedGames(home: home), [], "no cache yet")+ let owned = [GOGStore.Game(id: "1440148836", title: "Fallout"), GOGStore.Game(id: "1207658924", title: "Heretic", listsMac: true)]+ let cache: [String: Any] = [+ "epicOwned": [["appName": "Fortnite", "title": "Fortnite"]],+ "epicInstalls": [String: String](),+ "gogGames": try JSONSerialization.jsonObject(with: JSONEncoder().encode(owned)),+ ]+ try JSONSerialization.data(withJSONObject: cache).write(to: home.appending(path: "library-cache.json"))+ XCTAssertEqual(GOGStore.lastSeenOwnedGames(home: home), owned)+ try Data("not json".utf8).write(to: home.appending(path: "library-cache.json"))+ XCTAssertEqual(GOGStore.lastSeenOwnedGames(home: home), [], "a damaged cache lists nothing rather than failing")+ }}