Skip to content

Commit 51387c4

Browse files
committed
Simplified loop in LibraryInstall function
1 parent 9ea0101 commit 51387c4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Diff for: commands/lib/install.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,22 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
7777
if err != nil {
7878
return err
7979
}
80-
libReleasesToInstall = append(libReleasesToInstall, libRelease)
81-
}
82-
83-
// Check if any of the libraries to install is already installed and remove it from the list
84-
j := 0
85-
for i, libRelease := range libReleasesToInstall {
8680
_, libReplaced, err := lm.InstallPrerequisiteCheck(libRelease.Library.Name, libRelease.Version, installLocation)
8781
if errors.Is(err, librariesmanager.ErrAlreadyInstalled) {
8882
taskCB(&rpc.TaskProgress{Message: tr("Already installed %s", libRelease), Completed: true})
89-
} else if err != nil {
83+
continue
84+
}
85+
if err != nil {
9086
return err
91-
} else {
92-
libReleasesToInstall[j] = libReleasesToInstall[i]
93-
j++
9487
}
88+
9589
if req.GetNoOverwrite() {
9690
if libReplaced != nil {
9791
return fmt.Errorf(tr("Library %[1]s is already installed, but with a different version: %[2]s", libRelease, libReplaced))
9892
}
9993
}
94+
libReleasesToInstall = append(libReleasesToInstall, libRelease)
10095
}
101-
libReleasesToInstall = libReleasesToInstall[:j]
10296

10397
didInstall := false
10498
for _, libRelease := range libReleasesToInstall {

0 commit comments

Comments
 (0)