mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Use proper Caches directory
This commit is contained in:
1 parent
6fb3eee91b
commit
f9dc70ade2
2 files changed
+8
-4
No files matched your search
@@ -15,9 +15,10 @@ func makeError(code: SUError, _ description: String) -> NSError {
|
||||
}
|
||||
|
||||
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String:[ArchiveItem]] {
|
||||
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast");
|
||||
let comparator = SUStandardVersionComparator();
|
||||
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, verbose:verbose))
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose:verbose))
|
||||
.sorted(by: {
|
||||
.orderedDescending == comparator.compareVersion($0.version, toVersion:$1.version)
|
||||
})
|
||||
|
||||
@@ -13,7 +13,11 @@ func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -
|
||||
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:]);
|
||||
|
||||
do {
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy);
|
||||
do {
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy);
|
||||
} catch {
|
||||
try fileManager.copyItem(at: itemPath, to: itemCopy);
|
||||
}
|
||||
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath:nil, decryptionPassword:nil) {
|
||||
unarchiver.unarchive(completionBlock: { (error: Error?) in
|
||||
if error != nil {
|
||||
@@ -39,8 +43,7 @@ func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -
|
||||
}
|
||||
}
|
||||
|
||||
func unarchiveUpdates(archivesSourceDir: URL, verbose: Bool) throws -> [ArchiveItem] {
|
||||
let archivesDestDir = archivesSourceDir.appendingPathComponent(".tmp");
|
||||
func unarchiveUpdates(archivesSourceDir: URL, archivesDestDir: URL, verbose: Bool) throws -> [ArchiveItem] {
|
||||
if verbose {
|
||||
print("Unarchiving to temp directory", archivesDestDir.path);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user