mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
🐛 Allow redownloads on macOS 12
This commit is contained in:
parent
c7a104a250
commit
a499822dd8
2 changed files with 19 additions and 8 deletions
|
@ -63,12 +63,20 @@ private func downloadWithRetries(
|
|||
/// Only works for free apps. Defaults to false.
|
||||
/// - Returns: A promise the completes when the download is complete.
|
||||
private func download(_ appID: UInt64, purchase: Bool = false) -> Promise<Void> {
|
||||
guard let account = ISStoreAccount.primaryAccount else {
|
||||
return Promise(error: MASError.notSignedIn)
|
||||
}
|
||||
var storeAccount: ISStoreAccount?
|
||||
if #available(macOS 12, *) {
|
||||
// Monterey obscured the user's account information, but still allows
|
||||
// redownloads without passing it to SSPurchase.
|
||||
// https://github.com/mas-cli/mas/issues/417
|
||||
} else {
|
||||
guard let account = ISStoreAccount.primaryAccount else {
|
||||
return Promise(error: MASError.notSignedIn)
|
||||
}
|
||||
|
||||
guard let storeAccount = account as? ISStoreAccount else {
|
||||
fatalError("Unable to cast StoreAccount to ISStoreAccount")
|
||||
storeAccount = account as? ISStoreAccount
|
||||
guard storeAccount != nil else {
|
||||
fatalError("Unable to cast StoreAccount to ISStoreAccount")
|
||||
}
|
||||
}
|
||||
|
||||
return Promise<SSPurchase> { seal in
|
||||
|
|
|
@ -13,7 +13,7 @@ typealias SSPurchaseCompletion =
|
|||
(_ purchase: SSPurchase?, _ completed: Bool, _ error: Error?, _ response: SSPurchaseResponse?) -> Void
|
||||
|
||||
extension SSPurchase {
|
||||
convenience init(adamId: UInt64, account: ISStoreAccount, purchase: Bool = false) {
|
||||
convenience init(adamId: UInt64, account: ISStoreAccount?, purchase: Bool = false) {
|
||||
self.init()
|
||||
|
||||
var parameters: [String: Any] = [
|
||||
|
@ -40,8 +40,11 @@ extension SSPurchase {
|
|||
.joined(separator: "&")
|
||||
|
||||
itemIdentifier = adamId
|
||||
accountIdentifier = account.dsID
|
||||
appleID = account.identifier
|
||||
|
||||
if let account = account {
|
||||
accountIdentifier = account.dsID
|
||||
appleID = account.identifier
|
||||
}
|
||||
|
||||
// Not sure if this is needed, but lets use it here.
|
||||
if purchase {
|
||||
|
|
Loading…
Reference in a new issue