Skip to content

Commit

Permalink
🐛 (LekaUpdater): Store lastValue and skip if value is equal in verifi…
Browse files Browse the repository at this point in the history
…cation file
  • Loading branch information
YannLocatelli authored and ladislas committed Sep 25, 2023
1 parent 8ceb75f commit b70a1c5
Showing 1 changed file with 5 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 Down Expand Up @@ -351,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 @@ -526,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 @@ -543,7 +546,7 @@ class UpdateProcessV130: UpdateProcessProtocol {
StateSettingDestinationPath(),
StateClearingFile(),
stateSendingFile,
StateVerifyingFile(),
stateVerifyingFile,
StateApplyingUpdate(),
StateWaitingForRobotToReboot(),

Expand Down

0 comments on commit b70a1c5

Please sign in to comment.