Browse Source

Check that app is installed before uninstalling it

When trying to uninstall an app that is not installed adb prints just
"Failure". This causes output parsing to fail and results in "panic:
runtime error: index out of range" in adb.getFailureCode().

Check whether an app is installed first and print an appropriate message
if it's not.
pull/21/head
relan 10 years ago committed by Daniel Martí
parent
commit
b191eec348
  1. 10
      cmd/fdroidcl/uninstall.go

10
cmd/fdroidcl/uninstall.go

@ -4,6 +4,7 @@
package main
import (
"errors"
"fmt"
"log"
)
@ -22,9 +23,16 @@ func runUninstall(args []string) {
log.Fatalf("No package names given")
}
device := mustOneDevice()
inst := mustInstalled(device)
for _, id := range args {
var err error
fmt.Printf("Uninstalling %s... ", id)
if err := device.Uninstall(id); err != nil {
if _, installed := inst[id]; installed {
err = device.Uninstall(id)
} else {
err = errors.New("not installed")
}
if err != nil {
fmt.Println()
log.Fatalf("Could not uninstall %s: %v", id, err)
}

Loading…
Cancel
Save