Skip to content

Commit e6c02a7

Browse files
committed
simplify parsing
1 parent 3fdc669 commit e6c02a7

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

internal/updater/flasher.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/hex"
2222
"fmt"
2323
"log/slog"
24-
"regexp"
2524
"runtime"
2625
"strconv"
2726
"strings"
@@ -287,28 +286,21 @@ const (
287286
Flasherd Op = 2
288287
)
289288

290-
var qdlProgressRegex = regexp.MustCompile(`(\w)\s+(:?(".*?")\s+(\w+)(?:\s+at\s+(\d+kB/s))?)?`)
291-
292289
type QDLLogLine struct {
293290
Op Op
294291
Log string
295292
}
296293

297294
func parseQdlLogLine(line string) (QDLLogLine, error) {
298-
matches := qdlProgressRegex.FindStringSubmatch(line)
299-
if matches == nil {
300-
return QDLLogLine{}, fmt.Errorf("line %q does not match progress format", line)
301-
}
302-
slog.Debug("parsed qdl log line", "full", matches[0], "matches", matches)
303-
304-
if strings.HasPrefix(matches[1], "Waiting for") || strings.HasPrefix(matches[1], "waiting for") {
295+
line = strings.ToLower(line)
296+
if strings.HasPrefix(line, "waiting for") {
305297
return QDLLogLine{
306298
Op: Waiting,
307299
Log: line,
308300
}, nil
309301
}
310302

311-
if strings.HasPrefix(matches[1], "Flashed") {
303+
if strings.HasPrefix(line, "flashed") {
312304
return QDLLogLine{
313305
Op: Flasherd,
314306
Log: line,

service/service_flash.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func (s *flasherServerImpl) Flash(req *flasher.FlashRequest, stream flasher.Flas
6464
Name: msg.GetName(),
6565
Message: msg.GetMessage(),
6666
Completed: msg.GetCompleted(),
67+
Progress: msg.GetProgress(),
68+
Total: msg.GetTotal(),
6769
},
6870
},
6971
})

0 commit comments

Comments
 (0)