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

Yann/fix/lekaupdater/bug on sha256 verification #319

Merged
merged 2 commits into from
Sep 25, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ private class StateVerifyingFile: GKState, StateEventProcessor {
private var cancellables: Set<AnyCancellable> = []

private var isFileValid = false
private var lastValue = "0000000000000000000000000000000000000000000000000000000000000000"

private var nextStateIsClearingFile = false

Expand All @@ -312,6 +313,8 @@ private class StateVerifyingFile: GKState, StateEventProcessor {
override func didEnter(from previousState: GKState?) {
if previousState is StateSettingDestinationPath {
nextStateIsClearingFile = true
} else {
nextStateIsClearingFile = false
}

DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: startFileVerification)
Expand Down Expand Up @@ -349,9 +352,10 @@ private class StateVerifyingFile: GKState, StateEventProcessor {
.sink { value in
guard let value = value else { return }

if value == "0000000000000000000000000000000000000000000000000000000000000000" {
if value == self.lastValue {
return
}
self.lastValue = value

self.isFileValid = value == globalFirmwareManager.sha256
self.process(event: .fileVerificationReceived)
Expand Down Expand Up @@ -524,6 +528,7 @@ class UpdateProcessV130: UpdateProcessProtocol {

private var stateMachine: GKStateMachine?
private var stateSendingFile = StateSendingFile()
private var stateVerifyingFile = StateVerifyingFile()

private var cancellables: Set<AnyCancellable> = []

Expand All @@ -541,7 +546,7 @@ class UpdateProcessV130: UpdateProcessProtocol {
StateSettingDestinationPath(),
StateClearingFile(),
stateSendingFile,
StateVerifyingFile(),
stateVerifyingFile,
StateApplyingUpdate(),
StateWaitingForRobotToReboot(),

Expand Down