From 7d2699b42950cc16dad4b13855813842657bf884 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 27 Jun 2015 14:36:46 +0200 Subject: [PATCH] cmd/restic: Rename variable, no functional changes --- cmd/restic/cmd_backup.go | 10 +++++----- cmd/restic/cmd_cache.go | 6 +++--- cmd/restic/cmd_cat.go | 24 ++++++++++++------------ cmd/restic/cmd_find.go | 10 +++++----- cmd/restic/cmd_fsck.go | 14 +++++++------- cmd/restic/cmd_key.go | 12 ++++++------ cmd/restic/cmd_list.go | 8 ++++---- cmd/restic/cmd_ls.go | 10 +++++----- cmd/restic/cmd_restore.go | 8 ++++---- cmd/restic/cmd_snapshots.go | 8 ++++---- 10 files changed, 55 insertions(+), 55 deletions(-) diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 2ab9dc5e0..c377c5cad 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -215,12 +215,12 @@ func (cmd CmdBackup) Execute(args []string) error { target = append(target, d) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } @@ -229,7 +229,7 @@ func (cmd CmdBackup) Execute(args []string) error { // Force using a parent if !cmd.Force && cmd.Parent != "" { - parentSnapshotID, err = restic.FindSnapshot(s, cmd.Parent) + parentSnapshotID, err = restic.FindSnapshot(repo, cmd.Parent) if err != nil { return fmt.Errorf("invalid id %q: %v", cmd.Parent, err) } @@ -239,7 +239,7 @@ func (cmd CmdBackup) Execute(args []string) error { // Find last snapshot to set it as parent, if not already set if !cmd.Force && parentSnapshotID == nil { - parentSnapshotID, err = findLatestSnapshot(s, target) + parentSnapshotID, err = findLatestSnapshot(repo, target) if err != nil { return err } @@ -258,7 +258,7 @@ func (cmd CmdBackup) Execute(args []string) error { // return true // } - arch := restic.NewArchiver(s) + arch := restic.NewArchiver(repo) arch.Error = func(dir string, fi os.FileInfo, err error) error { // TODO: make ignoring errors configurable diff --git a/cmd/restic/cmd_cache.go b/cmd/restic/cmd_cache.go index 26a6b7970..011fb3e23 100644 --- a/cmd/restic/cmd_cache.go +++ b/cmd/restic/cmd_cache.go @@ -29,18 +29,18 @@ func (cmd CmdCache) Execute(args []string) error { // return fmt.Errorf("wrong number of parameters, Usage: %s", cmd.Usage()) // } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } - cache, err := restic.NewCache(s, cmd.global.CacheDir) + cache, err := restic.NewCache(repo, cmd.global.CacheDir) if err != nil { return err } fmt.Printf("clear cache for old snapshots\n") - err = cache.Clear(s) + err = cache.Clear(repo) if err != nil { return err } diff --git a/cmd/restic/cmd_cat.go b/cmd/restic/cmd_cat.go index 4356c1d51..fc4ebc721 100644 --- a/cmd/restic/cmd_cat.go +++ b/cmd/restic/cmd_cat.go @@ -37,7 +37,7 @@ func (cmd CmdCat) Execute(args []string) error { return fmt.Errorf("type or ID not specified, Usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } @@ -55,7 +55,7 @@ func (cmd CmdCat) Execute(args []string) error { } // find snapshot id with prefix - id, err = restic.FindSnapshot(s, args[1]) + id, err = restic.FindSnapshot(repo, args[1]) if err != nil { return err } @@ -65,7 +65,7 @@ func (cmd CmdCat) Execute(args []string) error { // handle all types that don't need an index switch tpe { case "config": - buf, err := json.MarshalIndent(s.Config, "", " ") + buf, err := json.MarshalIndent(repo.Config, "", " ") if err != nil { return err } @@ -73,7 +73,7 @@ func (cmd CmdCat) Execute(args []string) error { fmt.Println(string(buf)) return nil case "index": - buf, err := s.Load(backend.Index, id) + buf, err := repo.Load(backend.Index, id) if err != nil { return err } @@ -83,7 +83,7 @@ func (cmd CmdCat) Execute(args []string) error { case "snapshot": sn := &restic.Snapshot{} - err = s.LoadJSONUnpacked(backend.Snapshot, id, sn) + err = repo.LoadJSONUnpacked(backend.Snapshot, id, sn) if err != nil { return err } @@ -97,7 +97,7 @@ func (cmd CmdCat) Execute(args []string) error { return nil case "key": - rd, err := s.Backend().Get(backend.Key, id.String()) + rd, err := repo.Backend().Get(backend.Key, id.String()) if err != nil { return err } @@ -118,7 +118,7 @@ func (cmd CmdCat) Execute(args []string) error { fmt.Println(string(buf)) return nil case "masterkey": - buf, err := json.MarshalIndent(s.Key(), "", " ") + buf, err := json.MarshalIndent(repo.Key(), "", " ") if err != nil { return err } @@ -126,7 +126,7 @@ func (cmd CmdCat) Execute(args []string) error { fmt.Println(string(buf)) return nil case "lock": - lock, err := restic.LoadLock(s, id) + lock, err := restic.LoadLock(repo, id) if err != nil { return err } @@ -142,14 +142,14 @@ func (cmd CmdCat) Execute(args []string) error { } // load index, handle all the other types - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } switch tpe { case "pack": - rd, err := s.Backend().Get(backend.Data, id.String()) + rd, err := repo.Backend().Get(backend.Data, id.String()) if err != nil { return err } @@ -158,7 +158,7 @@ func (cmd CmdCat) Execute(args []string) error { return err case "blob": - data, err := s.LoadBlob(pack.Data, id) + data, err := repo.LoadBlob(pack.Data, id) if err == nil { _, err = os.Stdout.Write(data) return err @@ -170,7 +170,7 @@ func (cmd CmdCat) Execute(args []string) error { case "tree": debug.Log("cat", "cat tree %v", id.Str()) tree := restic.NewTree() - err = s.LoadJSONPack(pack.Tree, id, tree) + err = repo.LoadJSONPack(pack.Tree, id, tree) if err != nil { debug.Log("cat", "unable to load tree %v: %v", id.Str(), err) return err diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index c1a56ebc6..103e70cbd 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -157,7 +157,7 @@ func (c CmdFind) Execute(args []string) error { } } - s, err := c.global.OpenRepository() + repo, err := c.global.OpenRepository() if err != nil { return err } @@ -165,18 +165,18 @@ func (c CmdFind) Execute(args []string) error { c.pattern = args[0] if c.Snapshot != "" { - snapshotID, err := restic.FindSnapshot(s, c.Snapshot) + snapshotID, err := restic.FindSnapshot(repo, c.Snapshot) if err != nil { return fmt.Errorf("invalid id %q: %v", args[1], err) } - return c.findInSnapshot(s, snapshotID) + return c.findInSnapshot(repo, snapshotID) } done := make(chan struct{}) defer close(done) - for snapshotID := range s.List(backend.Snapshot, done) { - err := c.findInSnapshot(s, snapshotID) + for snapshotID := range repo.List(backend.Snapshot, done) { + err := c.findInSnapshot(repo, snapshotID) if err != nil { return err diff --git a/cmd/restic/cmd_fsck.go b/cmd/restic/cmd_fsck.go index 17a0608ce..6b8a8e1c6 100644 --- a/cmd/restic/cmd_fsck.go +++ b/cmd/restic/cmd_fsck.go @@ -190,23 +190,23 @@ func (cmd CmdFsck) Execute(args []string) error { cmd.Orphaned = true } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } if cmd.Snapshot != "" { - id, err := restic.FindSnapshot(s, cmd.Snapshot) + id, err := restic.FindSnapshot(repo, cmd.Snapshot) if err != nil { return fmt.Errorf("invalid id %q: %v", cmd.Snapshot, err) } - err = fsckSnapshot(cmd, s, id) + err = fsckSnapshot(cmd, repo, id) if err != nil { fmt.Fprintf(os.Stderr, "check for snapshot %v failed\n", id) } @@ -223,8 +223,8 @@ func (cmd CmdFsck) Execute(args []string) error { defer close(done) var firstErr error - for id := range s.List(backend.Snapshot, done) { - err = fsckSnapshot(cmd, s, id) + for id := range repo.List(backend.Snapshot, done) { + err = fsckSnapshot(cmd, repo, id) if err != nil { fmt.Fprintf(os.Stderr, "check for snapshot %v failed\n", id) firstErr = err @@ -241,7 +241,7 @@ func (cmd CmdFsck) Execute(args []string) error { cnt[pack.Data] = cmd.o_data cnt[pack.Tree] = cmd.o_trees - for blob := range s.Index().Each(done) { + for blob := range repo.Index().Each(done) { debug.Log("restic.fsck", "checking %v blob %v\n", blob.Type, blob.ID) err = cnt[blob.Type].Find(blob.ID) diff --git a/cmd/restic/cmd_key.go b/cmd/restic/cmd_key.go index ad1a358fd..19d73c4f6 100644 --- a/cmd/restic/cmd_key.go +++ b/cmd/restic/cmd_key.go @@ -116,25 +116,25 @@ func (cmd CmdKey) Execute(args []string) error { return fmt.Errorf("wrong number of arguments, Usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } switch args[0] { case "list": - return cmd.listKeys(s) + return cmd.listKeys(repo) case "add": - return cmd.addKey(s) + return cmd.addKey(repo) case "rm": - id, err := backend.Find(s.Backend(), backend.Key, args[1]) + id, err := backend.Find(repo.Backend(), backend.Key, args[1]) if err != nil { return err } - return cmd.deleteKey(s, id) + return cmd.deleteKey(repo, id) case "passwd": - return cmd.changePassword(s) + return cmd.changePassword(repo) } return nil diff --git a/cmd/restic/cmd_list.go b/cmd/restic/cmd_list.go index bd01e6eda..95fe68db6 100644 --- a/cmd/restic/cmd_list.go +++ b/cmd/restic/cmd_list.go @@ -30,7 +30,7 @@ func (cmd CmdList) Execute(args []string) error { return fmt.Errorf("type not specified, Usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } @@ -38,12 +38,12 @@ func (cmd CmdList) Execute(args []string) error { var t backend.Type switch args[0] { case "blobs": - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } - for blob := range s.Index().Each(nil) { + for blob := range repo.Index().Each(nil) { cmd.global.Printf("%s\n", blob.ID) } @@ -62,7 +62,7 @@ func (cmd CmdList) Execute(args []string) error { return errors.New("invalid type") } - for id := range s.List(t, nil) { + for id := range repo.List(t, nil) { cmd.global.Printf("%s\n", id) } diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index 59144befc..8ec904bbd 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -69,27 +69,27 @@ func (cmd CmdLs) Execute(args []string) error { return fmt.Errorf("wrong number of arguments, Usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } - id, err := restic.FindSnapshot(s, args[0]) + id, err := restic.FindSnapshot(repo, args[0]) if err != nil { return err } - sn, err := restic.LoadSnapshot(s, id) + sn, err := restic.LoadSnapshot(repo, id) if err != nil { return err } fmt.Printf("snapshot of %v at %s:\n", sn.Paths, sn.Time) - return printTree("", s, sn.Tree) + return printTree("", repo, sn.Tree) } diff --git a/cmd/restic/cmd_restore.go b/cmd/restic/cmd_restore.go index 1f3697d4d..f70d2fc6a 100644 --- a/cmd/restic/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -30,17 +30,17 @@ func (cmd CmdRestore) Execute(args []string) error { return fmt.Errorf("wrong number of arguments, Usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } - err = s.LoadIndex() + err = repo.LoadIndex() if err != nil { return err } - id, err := restic.FindSnapshot(s, args[0]) + id, err := restic.FindSnapshot(repo, args[0]) if err != nil { cmd.global.Exitf(1, "invalid id %q: %v", args[0], err) } @@ -48,7 +48,7 @@ func (cmd CmdRestore) Execute(args []string) error { target := args[1] // create restorer - res, err := restic.NewRestorer(s, id) + res, err := restic.NewRestorer(repo, id) if err != nil { cmd.global.Exitf(2, "creating restorer failed: %v\n", err) } diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go index f1f8ba31e..2ffb1d8b1 100644 --- a/cmd/restic/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -94,7 +94,7 @@ func (cmd CmdSnapshots) Execute(args []string) error { return fmt.Errorf("wrong number of arguments, usage: %s", cmd.Usage()) } - s, err := cmd.global.OpenRepository() + repo, err := cmd.global.OpenRepository() if err != nil { return err } @@ -107,8 +107,8 @@ func (cmd CmdSnapshots) Execute(args []string) error { defer close(done) list := []*restic.Snapshot{} - for id := range s.List(backend.Snapshot, done) { - sn, err := restic.LoadSnapshot(s, id) + for id := range repo.List(backend.Snapshot, done) { + sn, err := restic.LoadSnapshot(repo, id) if err != nil { fmt.Fprintf(os.Stderr, "error loading snapshot %s: %v\n", id, err) continue @@ -127,7 +127,7 @@ func (cmd CmdSnapshots) Execute(args []string) error { } } - plen, err := s.PrefixLength(backend.Snapshot) + plen, err := repo.PrefixLength(backend.Snapshot) if err != nil { return err }