mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
Adds option to not cache downloaded app during installation
This commit is contained in:
@@ -486,7 +486,7 @@ private extension AppManager
|
|||||||
return group
|
return group
|
||||||
}
|
}
|
||||||
|
|
||||||
private func _install(_ app: AppProtocol, operation: AppOperation, group: RefreshGroup, additionalEntitlements: [ALTEntitlement: Any]? = nil, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
private func _install(_ app: AppProtocol, operation: AppOperation, group: RefreshGroup, additionalEntitlements: [ALTEntitlement: Any]? = nil, cacheApp: Bool = true, completionHandler: @escaping (Result<InstalledApp, Error>) -> Void) -> Progress
|
||||||
{
|
{
|
||||||
let progress = Progress.discreteProgress(totalUnitCount: 100)
|
let progress = Progress.discreteProgress(totalUnitCount: 100)
|
||||||
|
|
||||||
@@ -514,13 +514,24 @@ private extension AppManager
|
|||||||
downloadingApp = storeApp
|
downloadingApp = storeApp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let downloadedAppURL = context.temporaryDirectory.appendingPathComponent("Cached.app")
|
||||||
|
|
||||||
/* Download */
|
/* Download */
|
||||||
let downloadOperation = DownloadAppOperation(app: downloadingApp, context: context)
|
let downloadOperation = DownloadAppOperation(app: downloadingApp, destinationURL: downloadedAppURL, context: context)
|
||||||
downloadOperation.resultHandler = { (result) in
|
downloadOperation.resultHandler = { (result) in
|
||||||
switch result
|
do
|
||||||
{
|
{
|
||||||
case .failure(let error): context.error = error
|
let app = try result.get()
|
||||||
case .success(let app): context.app = app
|
context.app = app
|
||||||
|
|
||||||
|
if cacheApp
|
||||||
|
{
|
||||||
|
try FileManager.default.copyItem(at: app.fileURL, to: InstalledApp.fileURL(for: app), shouldReplace: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
context.error = error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress.addChild(downloadOperation.progress, withPendingUnitCount: 25)
|
progress.addChild(downloadOperation.progress, withPendingUnitCount: 25)
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ class DownloadAppOperation: ResultOperation<ALTApplication>
|
|||||||
|
|
||||||
private let session = URLSession(configuration: .default)
|
private let session = URLSession(configuration: .default)
|
||||||
|
|
||||||
init(app: AppProtocol, context: AppOperationContext)
|
init(app: AppProtocol, destinationURL: URL, context: AppOperationContext)
|
||||||
{
|
{
|
||||||
self.app = app
|
self.app = app
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
self.bundleIdentifier = app.bundleIdentifier
|
self.bundleIdentifier = app.bundleIdentifier
|
||||||
self.sourceURL = app.url
|
self.sourceURL = app.url
|
||||||
self.destinationURL = InstalledApp.fileURL(for: app)
|
self.destinationURL = destinationURL
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user