diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index a4c9cd80..d22b6e57 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -1320,7 +1320,8 @@ private extension AppManager if cacheApp { - try FileManager.default.copyItem(at: app.fileURL, to: InstalledApp.fileURL(for: app), shouldReplace: true) + let updatedApp = AnyApp(from: app, bundleId: context.bundleIdentifier) + try FileManager.default.copyItem(at: app.fileURL, to: InstalledApp.fileURL(for: updatedApp), shouldReplace: true) } } catch diff --git a/AltStore/Operations/DownloadAppOperation.swift b/AltStore/Operations/DownloadAppOperation.swift index 7a1890a3..0131c43a 100644 --- a/AltStore/Operations/DownloadAppOperation.swift +++ b/AltStore/Operations/DownloadAppOperation.swift @@ -38,7 +38,7 @@ final class DownloadAppOperation: ResultOperation self.context = context self.appName = app.name - self.bundleIdentifier = app.bundleIdentifier + self.bundleIdentifier = context.bundleIdentifier self.sourceURL = app.url self.destinationURL = destinationURL @@ -77,7 +77,7 @@ final class DownloadAppOperation: ResultOperation guard let latestVersion = storeApp.latestAvailableVersion else { let failureReason = String(format: NSLocalizedString("The latest version of %@ could not be determined.", comment: ""), self.appName) throw OperationError.unknown(failureReason: failureReason) - } + } // Attempt to download latest _available_ version, and fall back to older versions if necessary. appVersion = latestVersion diff --git a/AltStoreCore/Protocols/AppProtocol.swift b/AltStoreCore/Protocols/AppProtocol.swift index 98cda889..aaae28a7 100644 --- a/AltStoreCore/Protocols/AppProtocol.swift +++ b/AltStoreCore/Protocols/AppProtocol.swift @@ -32,6 +32,13 @@ public struct AnyApp: AppProtocol self.url = url self.storeApp = storeApp } + + public init(from app: AppProtocol, name: String? = nil, bundleId: String? = nil, url: URL? = nil, storeApp: StoreApp? = nil) { + self.name = name ?? app.name + self.bundleIdentifier = bundleId ?? app.bundleIdentifier + self.url = url ?? app.url + self.storeApp = storeApp ?? app.storeApp + } } extension ALTApplication: AppProtocol