mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Verify applying delta patch in generate_appcast (#2076)
This commit is contained in:
2 files changed
+18
-2
No files matched your search
@@ -25,11 +25,26 @@ class DeltaUpdate {
|
||||
}
|
||||
|
||||
class func create(from: ArchiveItem, to: ArchiveItem, deltaVersion: SUBinaryDeltaMajorVersion, deltaCompressionMode: SPUDeltaCompressionMode, deltaCompressionLevel: UInt8, archivePath: URL) throws -> DeltaUpdate {
|
||||
var applyDiffError: NSError?
|
||||
var createDiffError: NSError?
|
||||
|
||||
if !createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, deltaVersion, deltaCompressionMode, deltaCompressionLevel, false, &applyDiffError) {
|
||||
if !createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, deltaVersion, deltaCompressionMode, deltaCompressionLevel, false, &createDiffError) {
|
||||
throw createDiffError!
|
||||
}
|
||||
|
||||
// Ensure applying the diff also succeeds
|
||||
let fileManager = FileManager.default
|
||||
|
||||
let tempApplyToPath = to.appPath.deletingLastPathComponent().appendingPathComponent(".temp_" + to.appPath.lastPathComponent)
|
||||
let _ = try? fileManager.removeItem(at: tempApplyToPath)
|
||||
|
||||
var applyDiffError: NSError?
|
||||
if !applyBinaryDelta(from.appPath.path, tempApplyToPath.path, archivePath.path, false, { _ in
|
||||
}, &applyDiffError) {
|
||||
let _ = try? fileManager.removeItem(at: archivePath)
|
||||
throw applyDiffError!
|
||||
}
|
||||
|
||||
let _ = try? fileManager.removeItem(at: tempApplyToPath)
|
||||
|
||||
return DeltaUpdate(fromVersion: from.version, archivePath: archivePath)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SPUInstallationType.h"
|
||||
|
||||
Reference in new issue
Block a user