Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify applying delta patch in generate_appcast #2076

Merged
merged 2 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions generate_appcast/ArchiveItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions generate_appcast/Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down