cmd/restic: Rename variable, no functional changes

This commit is contained in:
Alexander Neumann 2015-06-27 14:36:46 +02:00
parent fba912440d
commit 7d2699b429
10 changed files with 55 additions and 55 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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
}