1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

ls: Check dirs before opening the repository

Users get feedback instantly, and before any expensive network calls
have been made.
This commit is contained in:
Alexander Neumann 2018-08-12 21:59:57 +02:00
parent 11ce572894
commit 0deb4e5994

View file

@ -65,15 +65,6 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
return errors.Fatal("Invalid arguments, either give one or more snapshot IDs or set filters.")
}
repo, err := OpenRepository(gopts)
if err != nil {
return err
}
if err = repo.LoadIndex(gopts.ctx); err != nil {
return err
}
// extract any specific directories to walk
var dirs []string
if len(args) > 1 {
@ -85,6 +76,15 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
}
}
repo, err := OpenRepository(gopts)
if err != nil {
return err
}
if err = repo.LoadIndex(gopts.ctx); err != nil {
return err
}
ctx, cancel := context.WithCancel(gopts.ctx)
defer cancel()
for sn := range FindFilteredSnapshots(ctx, repo, opts.Host, opts.Tags, opts.Paths, args[:1]) {