Rename types and errmsg function

This commit is contained in:
Alexander Neumann
2014-08-03 15:16:56 +02:00
parent 5cbd1d0090
commit fbd33636f0
5 changed files with 22 additions and 23 deletions

View File

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

View File

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

View File

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