Skip to content

Do not exit with an error if lib is not present #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions commands/lib/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ import (
// LibraryUninstall FIXMEDOC
func LibraryUninstall(ctx context.Context, req *rpc.LibraryUninstallReq, taskCB commands.TaskProgressCB) error {
lm := commands.GetLibraryManager(req)

lib, err := findLibrary(lm, req)
ref, err := createLibIndexReference(lm, req)
if err != nil {
return fmt.Errorf("looking for library: %s", err)
return err
}

taskCB(&rpc.TaskProgress{Name: "Uninstalling " + lib.String()})
lm.Uninstall(lib)
taskCB(&rpc.TaskProgress{Completed: true})
lib := lm.FindByReference(ref)

if lib == nil {
taskCB(&rpc.TaskProgress{Message: fmt.Sprintf("Library %s is not installed", req.Name), Completed: true})
} else {
taskCB(&rpc.TaskProgress{Name: "Uninstalling " + lib.String()})
lm.Uninstall(lib)
taskCB(&rpc.TaskProgress{Completed: true})
}

return nil
}
13 changes: 0 additions & 13 deletions commands/lib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package lib
import (
"fmt"

"github.com/arduino/arduino-cli/arduino/libraries"
"github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
"github.com/arduino/arduino-cli/commands"
Expand Down Expand Up @@ -51,15 +50,3 @@ func findLibraryIndexRelease(lm *librariesmanager.LibrariesManager, req libraryR
}
return lib, nil
}

func findLibrary(lm *librariesmanager.LibrariesManager, req libraryReferencer) (*libraries.Library, error) {
ref, err := createLibIndexReference(lm, req)
if err != nil {
return nil, err
}
lib := lm.FindByReference(ref)
if lib == nil {
return nil, fmt.Errorf("library %s is not installed", ref)
}
return lib, nil
}