Merge pull request #972 from sparkle-project/misc

Misc
This commit is contained in:
Kornel authored and GitHub committed 2017-01-04 00:07:29 +00:00
commit d50e823b3d
3 files changed
+11 -4

No files matched your search

+3 -1
View File
@@ -155,8 +155,10 @@ static NSString * const UPDATED_VERSION = @"2.0";
// Copy our appcast over to the server directory
NSURL *appcastDestinationURL = [[serverDirectoryURL URLByAppendingPathComponent:appcastName] URLByAppendingPathExtension:appcastExtension];
NSURL *appcastPath = [mainBundle URLForResource:appcastName withExtension:appcastExtension];
assert(appcastPath);
NSError *copyAppcastError = nil;
if (![fileManager copyItemAtURL:[mainBundle URLForResource:appcastName withExtension:appcastExtension] toURL:appcastDestinationURL error:&copyAppcastError]) {
if (![fileManager copyItemAtURL:appcastPath toURL:appcastDestinationURL error:&copyAppcastError]) {
NSLog(@"Failed to copy appcast into cache directory with error %@", copyAppcastError);
assert(NO);
}
+5 -2
View File
@@ -5,6 +5,9 @@
import Foundation
// Maximum number of delta updates (per OS).
let maxDeltas = 5;
func makeError(code: SUError, _ description: String) -> NSError {
return NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(code.rawValue)), userInfo: [
NSLocalizedDescriptionKey: description,
@@ -65,7 +68,7 @@ func makeAppcast(archivesSourceDir: URL, privateKey: SecKey) throws -> [String:[
continue;
}
let deltaBaseName = appBaseName + item.version + "-" + latestItem.version;
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version;
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta");
var delta:DeltaUpdate;
@@ -84,7 +87,7 @@ func makeAppcast(archivesSourceDir: URL, privateKey: SecKey) throws -> [String:[
if delta.fileSize / 7 < latestItem.fileSize / 8 {
// Max 3 deltas per version (arbitrary limit to reduce amount of work)
numDeltas += 1;
if numDeltas > 3 {
if numDeltas > maxDeltas {
break;
}
+3 -1
View File
@@ -5,6 +5,8 @@
import Foundation
let maxVersionsInFeed = 5;
func findElement(name: String, parent: XMLElement) -> XMLElement? {
if let found = try? parent.nodes(forXPath: name) {
if found.count > 0 {
@@ -79,7 +81,7 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
let createNewItem = existingItems.count == 0;
// Update all old items, but aim for less than 5 in new feeds
if createNewItem && numItems >= 5 {
if createNewItem && numItems >= maxVersionsInFeed {
continue;
}
numItems += 1;