Skip to content

Commit

Permalink
🔀 Merge branch 'yann/fix/lekaupdater/bug-on-sha256-verification'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Sep 25, 2023
2 parents 4b5a070 + b70a1c5 commit 68cdb86
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 68cdb86

Please sign in to comment.