diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2018-01-11 08:12:34 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2018-01-11 08:12:34 +0100 |
commit | 72c566f0f431184128de346a59deb6d9b264f084 (patch) | |
tree | 968f313e08dface0973cc35b0e39c2a751ad8820 /backup | |
parent | 24eaa21662699f090b5c8e6390651e6d0c1e448d (diff) | |
download | petrific-72c566f0f431184128de346a59deb6d9b264f084.tar.gz petrific-72c566f0f431184128de346a59deb6d9b264f084.tar.bz2 petrific-72c566f0f431184128de346a59deb6d9b264f084.zip |
Add logging to RestoreDir
Diffstat (limited to 'backup')
-rw-r--r-- | backup/restore.go | 7 | ||||
-rw-r--r-- | backup/restore_test.go | 3 |
2 files changed, 7 insertions, 3 deletions
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) } |