From 72c566f0f431184128de346a59deb6d9b264f084 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Thu, 11 Jan 2018 08:12:34 +0100 Subject: Add logging to RestoreDir --- backup/restore.go | 7 +++++-- backup/restore_test.go | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'backup') diff --git a/backup/restore.go b/backup/restore.go index 7624e1e..081d89b 100644 --- a/backup/restore.go +++ b/backup/restore.go @@ -3,6 +3,7 @@ package backup import ( "code.laria.me/petrific/acl" "code.laria.me/petrific/fs" + "code.laria.me/petrific/logging" "code.laria.me/petrific/objects" "code.laria.me/petrific/storage" "fmt" @@ -40,13 +41,15 @@ func execBitFromACL(a acl.ACL) bool { return a.ToUnixPerms()&0100 != 0 } -func RestoreDir(s storage.Storage, id objects.ObjectId, root fs.Dir) error { +func RestoreDir(s storage.Storage, id objects.ObjectId, root fs.Dir, log *logging.Log) error { tree_obj, err := storage.GetObjectOfType(s, id, objects.OTTree) tree := tree_obj.(objects.Tree) seen := make(map[string]struct{}) for name, file_info := range tree { + log.Info().Printf("restoring %s %s", name, file_info.Type()) + switch file_info.Type() { case objects.TETFile: tmpname := fmt.Sprintf(".petrific-%d-%08x%08x%08x%08x", os.Getpid(), rand.Uint32(), rand.Uint32(), rand.Uint32(), rand.Uint32()) @@ -94,7 +97,7 @@ func RestoreDir(s storage.Storage, id objects.ObjectId, root fs.Dir) error { } } - if err := RestoreDir(s, file_info.(objects.TreeEntryDir).Ref, subdir); err != nil { + if err := RestoreDir(s, file_info.(objects.TreeEntryDir).Ref, subdir, log); err != nil { return err } case objects.TETSymlink: diff --git a/backup/restore_test.go b/backup/restore_test.go index 96d2752..afe2c58 100644 --- a/backup/restore_test.go +++ b/backup/restore_test.go @@ -3,6 +3,7 @@ package backup import ( "bytes" "code.laria.me/petrific/fs" + "code.laria.me/petrific/logging" "code.laria.me/petrific/objects" "code.laria.me/petrific/storage/memory" "io" @@ -82,7 +83,7 @@ func TestRestoreDir(t *testing.T) { root := fs.NewMemoryFSRoot("") - if err := RestoreDir(s, objid_testtree, root); err != nil { + if err := RestoreDir(s, objid_testtree, root, logging.NewNopLog()); err != nil { t.Fatalf("Unexpected error from RestoreDir(): %s", err) } -- cgit v1.2.3-70-g09d2