Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

Merge branch 'fix/gog-save-safety' into feat/epic-cloud-saves

Gabe76c835a91f07
diff --cc Sources/HighballKit/GOGLibrary.swift
index 79564cf,e811096..0b4adad
--- a/Sources/HighballKit/GOGLibrary.swift
+++ b/Sources/HighballKit/GOGLibrary.swift
@@@ -551,13 -564,19 +551,18 @@@ extension GOGStore
return history
}
- /// The history file, or the marker's date. Not the info file's: setup and updates record
- /// from this, and setup runs after gogdl wrote the info file, so what it put down would
- /// count as the game's.
+ /// The history file, or for an install set up before it was kept (a marker, no history) the
+ /// earliest of the marker's date, the info file's and the game folder's creation: setup
+ /// rewrote the marker on every update before the history was kept, so the marker alone would
+ /// leave out saves written before the last update. That can also count files an old update
+ /// rewrote, which only copies more. Not the info file's for an install with no marker: setup
+ /// and updates record from this, and setup runs after gogdl wrote the info file, so what it
+ /// put down would count as the game's.
private static func storedHistory(for game: InstalledGame, driveC: URL) -> InstallHistory {
- var history = (try? Data(contentsOf: historyFile(for: game, driveC: driveC)))
- .flatMap { try? JSONDecoder().decode(InstallHistory.self, from: $0) } ?? InstallHistory()
+ var history = InstallHistory.read(historyFile(for: game, driveC: driveC)) ?? InstallHistory()
- if history.firstSetup == nil {
- history.firstSetup = try? setupMarker(for: game, driveC: driveC).resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate
+ if history.firstSetup == nil,
+ let marked = try? setupMarker(for: game, driveC: driveC).resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate {
+ history.firstSetup = [marked, installedDate(of: game)].compactMap { $0 }.min()
}
return history
}