Skip to content

Commit

Permalink
Revert unarchiver code to how it used to work in generate_appcast (#2556
Browse files Browse the repository at this point in the history
)

Also remove temp directory before extraction.
  • Loading branch information
zorgiepoo committed May 6, 2024
1 parent 56ad4aa commit d7db589
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 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) {
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) {
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 d7db589

Please sign in to comment.