Skip to content
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

Fix data-eating behavior of Repo.ReadNames() and friends #73

Merged
merged 2 commits into from
Mar 11, 2024
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
2 changes: 1 addition & 1 deletion down.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var downCmd = &cobra.Command{
// First, populate the initial list of packages to download.
var list []string
if downAll {
names, err := Repo.ReadNames(nil)
names, err := Repo.ReadAllNames(nil)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions repo/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (r *Repo) add(h errs.Handler, pkgfiles []string, ar func(string, string) er
}

pkgs, err := r.FindSimilar(h, added...)
if err != nil {
return err
}
return r.Dispatch(h, pu.Map(pkgs, pu.PkgFilename)...)
}

Expand Down
2 changes: 1 addition & 1 deletion repo/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *Repo) FindNewest(h errs.Handler, pkgnames ...string) (pacman.Packages,
var pkgs pacman.Packages
var err error
if len(pkgnames) == 0 {
pkgs, err = r.ReadDir(h)
pkgs, err = r.ReadAllNames(h)
} else {
pkgs, err = r.ReadNames(h, pkgnames...)
}
Expand Down
12 changes: 7 additions & 5 deletions repo/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ func (r *Repo) ReadDir(h errs.Handler) (pacman.Packages, error) {
}

// ReadNames returns all packages in the repository that match the given
// names. If no names are given, all packages found are returned.
// names. If no names are given, no packages are returned.
func (r *Repo) ReadNames(h errs.Handler, pkgnames ...string) (pacman.Packages, error) {
errs.Init(&h)
if len(pkgnames) == 0 {
return r.ReadDir(h)
}

pkgs, err := pacman.ReadNames(h, r.Directory, pkgnames...)
r.MakeAbs(pkgs)
return pkgs, err
}

// ReadAllNames returns all packages in the repository.
func (r *Repo) ReadAllNames(h errs.Handler) (pacman.Packages, error) {
errs.Init(&h)
return r.ReadDir(h)
}

// ReadMeta returns all meta packages in the repository that match the given
// names. If no names are given, all packages in repository are returned.
func (r *Repo) ReadMeta(h errs.Handler, pkgnames ...string) (meta.Packages, error) {
Expand Down
Loading