Fix path bugs in ArchiveUtil

This commit is contained in:
Lukhnos Liu 2022-02-14 00:39:40 -08:00
parent 39a9330969
commit 0697d8b233
1 changed files with 8 additions and 7 deletions

View File

@ -22,6 +22,7 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
import Cocoa import Cocoa
import Foundation
struct ArchiveUtil { struct ArchiveUtil {
var appName: String var appName: String
@ -95,16 +96,16 @@ struct ArchiveUtil {
unzipTask.waitUntilExit() unzipTask.waitUntilExit()
assert(unzipTask.terminationStatus == 0, "Must successfully unzipped") assert(unzipTask.terminationStatus == 0, "Must successfully unzipped")
guard let result = (tempFilePath as NSString).appendingPathExtension(targetAppBundleName) else { let result = (tempFilePath as NSString).appendingPathComponent(targetAppBundleName)
return nil assert(FileManager.default.fileExists(atPath: result), "App bundle must be unzipped at \(result).")
}
assert(FileManager.default.fileExists(atPath: result), "App bundle must be unzipped at \(resourcePath).")
return result return result
} }
private var notarizedArchivesPath: String? { private var notarizedArchivesPath: String? {
let resourePath = Bundle.main.resourcePath guard let resourePath = Bundle.main.resourcePath else {
let notarizedArchivesPath = resourePath?.appending("NotarizedArchives") return nil
}
let notarizedArchivesPath = (resourePath as NSString).appendingPathComponent("NotarizedArchives")
return notarizedArchivesPath return notarizedArchivesPath
} }
@ -114,7 +115,7 @@ struct ArchiveUtil {
return nil return nil
} }
let notarizedArchiveBasename = "\(appName)-r\(bundleVersion).zip" let notarizedArchiveBasename = "\(appName)-r\(bundleVersion).zip"
let notarizedArchive = notarizedArchivesPath.appending(notarizedArchiveBasename) let notarizedArchive = (notarizedArchivesPath as NSString).appendingPathComponent(notarizedArchiveBasename)
return notarizedArchive return notarizedArchive
} }