File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -283,10 +283,24 @@ func (fssize *FSSize) AccumulatePackages() error {
283
283
var builder strings.Builder
284
284
for _ , c := range output {
285
285
if c == '\n' {
286
- split := strings .Split (builder .String (), "," )
286
+ str := builder .String ()
287
+ if len (str ) == 0 {
288
+ panic ("unexpected output from dpkg-query, empty line" )
289
+ }
290
+
291
+ // dpkg-query can output nothing as the size sometimes, like here with surge-xt:
292
+ // 2508,sudo
293
+ // ,surge-xt
294
+ // 91,switcheroo-control
295
+ if str [0 ] == ',' {
296
+ continue
297
+ }
298
+
299
+ split := strings .Split (str , "," )
287
300
if len (split ) != 2 {
288
- panic ("unexpected output from dpkg-query, more than 1 comma in output" )
301
+ panic ("unexpected output from dpkg-query, failed to split line by comma in output" )
289
302
}
303
+
290
304
packageName := split [1 ]
291
305
estimatedKibibytes , err := strconv .Atoi (split [0 ])
292
306
if err != nil {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import (
16
16
)
17
17
18
18
const programName = "fssize"
19
- const version = "v0.0.2 "
19
+ const version = "v0.0.3 "
20
20
21
21
func printError (str string ) {
22
22
os .Stderr .WriteString ("\x1b [0;31m" + programName + ": " + str + "\x1b [0m\n " )
You can’t perform that action at this time.
0 commit comments