Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ef4f1db

Browse files
committedJun 26, 2024·
simplified code
1 parent d02c1c1 commit ef4f1db

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed
 

‎internal/ota-api/dto.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,11 @@ func hasReachedFlashState(states []State) bool {
183183
}
184184

185185
func formatStateData(state, data string, firmware_size int64, hasReceivedFlashState bool) string {
186-
if data == "" {
186+
if data == "" || data == "Unknown" {
187187
return ""
188188
}
189189
if state == "fetch" {
190190
// This is the state 'fetch' of OTA progress. This contains a number that represents the number of bytes fetched
191-
if data == "Unknown" {
192-
return ""
193-
}
194191
actualDownloadedData, err := strconv.Atoi(data)
195192
if err != nil || actualDownloadedData <= 0 || firmware_size <= 0 { // Sanitize and avoid division by zero
196193
return data
@@ -201,9 +198,6 @@ func formatStateData(state, data string, firmware_size int64, hasReceivedFlashSt
201198
percentage := (float64(actualDownloadedData) / float64(firmware_size)) * 100
202199
return buildSimpleProgressBar(percentage)
203200
}
204-
if data == "Unknown" {
205-
return ""
206-
}
207201
return data
208202
}
209203

0 commit comments

Comments
 (0)
Please sign in to comment.