mirror of
https://github.com/restic/restic.git
synced 2025-12-10 05:02:17 +00:00
Rename types and errmsg function
This commit is contained in:
@@ -70,7 +70,7 @@ func archive_dir(repo *khepri.DirRepository, path string) (khepri.ID, error) {
|
||||
|
||||
var buf bytes.Buffer
|
||||
t.Save(&buf)
|
||||
id, err := repo.PutRaw(khepri.TypeRef, buf.Bytes())
|
||||
id, err := repo.PutRaw(khepri.TYPE_BLOB, buf.Bytes())
|
||||
|
||||
if err != nil {
|
||||
log.Printf("error saving tree to repo: %v", err)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func restore_file(repo *khepri.DirRepository, node khepri.Node, target string) error {
|
||||
fmt.Printf(" restore file %q\n", target)
|
||||
|
||||
rd, err := repo.Get(khepri.TypeBlob, node.Content)
|
||||
rd, err := repo.Get(khepri.TYPE_BLOB, node.Content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func restore_file(repo *khepri.DirRepository, node khepri.Node, target string) e
|
||||
|
||||
func restore_dir(repo *khepri.DirRepository, id khepri.ID, target string) error {
|
||||
fmt.Printf(" restore dir %q\n", target)
|
||||
rd, err := repo.Get(khepri.TypeRef, id)
|
||||
rd, err := repo.Get(khepri.TYPE_REF, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func commandRestore(repo *khepri.DirRepository, args []string) error {
|
||||
|
||||
id, err := khepri.ParseID(args[0])
|
||||
if err != nil {
|
||||
errmsg(1, "invalid id %q: %v", args[0], err)
|
||||
errx(1, "invalid id %q: %v", args[0], err)
|
||||
}
|
||||
|
||||
target := args[1]
|
||||
|
||||
@@ -14,7 +14,7 @@ var Opts struct {
|
||||
Repo string `short:"r" long:"repo" description:"Repository directory to backup to/restor from"`
|
||||
}
|
||||
|
||||
func errmsg(code int, format string, data ...interface{}) {
|
||||
func errx(code int, format string, data ...interface{}) {
|
||||
if len(format) > 0 && format[len(format)-1] != '\n' {
|
||||
format += "\n"
|
||||
}
|
||||
@@ -58,17 +58,17 @@ func main() {
|
||||
|
||||
f, ok := commands[cmd]
|
||||
if !ok {
|
||||
errmsg(1, "unknown command: %q\n", cmd)
|
||||
errx(1, "unknown command: %q\n", cmd)
|
||||
}
|
||||
|
||||
repo, err := khepri.NewDirRepository(Opts.Repo)
|
||||
|
||||
if err != nil {
|
||||
errmsg(1, "unable to create/open repo: %v", err)
|
||||
errx(1, "unable to create/open repo: %v", err)
|
||||
}
|
||||
|
||||
err = f(repo, args[1:])
|
||||
if err != nil {
|
||||
errmsg(1, "error executing command %q: %v", cmd, err)
|
||||
errx(1, "error executing command %q: %v", cmd, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user