Expose magic numbers

This commit is contained in:
Kornel Lesiński committed 2017-01-01 14:14:25 +00:00
1 parent 9c0ccd4a57
commit 271d504f6d
2 files changed
+7 -2

No files matched your search

+4 -1
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,
@@ -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;