Skip to content

Commit

Permalink
Create and use temp extraction directory in generate_appcast again (#…
Browse files Browse the repository at this point in the history
…2555)

This restores how the code used to work in 2.6.0 except we don't create a link to the archive file, and remove the temp directory before starting. I had removed too much of the prior code in 2.6.1 which included creating the extraction directory in generate_appcast.
  • Loading branch information
zorgiepoo authored May 4, 2024
1 parent 026cf54 commit 946c583
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions generate_appcast/Unarchive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,28 @@
import Foundation

func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemPath.path, extractionDirectory: archiveDestDir.path, updatingHostBundlePath: nil, decryptionPassword: nil, expectingInstallationType: SPUInstallationTypeApplication) {
let fileManager = FileManager.default
let tempDir = archiveDestDir.appendingPathExtension("tmp")

_ = try? fileManager.removeItem(at: tempDir)
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:])

if let unarchiver = SUUnarchiver.unarchiver(forPath: itemPath.path, extractionDirectory: tempDir.path, updatingHostBundlePath: nil, decryptionPassword: nil, expectingInstallationType: SPUInstallationTypeApplication) {
unarchiver.unarchive(completionBlock: { (error: Error?) in
if error != nil {
callback(error)
return
}

callback(nil)
do {
try fileManager.moveItem(at: tempDir, to: archiveDestDir)
callback(nil)
} catch {
callback(error)
}
}, progressBlock: nil)
} else {
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemPath)"))
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemPath.path)"))
}
}

Expand Down

0 comments on commit 946c583

Please sign in to comment.