aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backup/restore.go7
-rw-r--r--backup/restore_test.go3
-rw-r--r--restore_dir.go2
-rw-r--r--snapshot.go2
4 files changed, 9 insertions, 5 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)
}
diff --git a/restore_dir.go b/restore_dir.go
index 1ed8a11..e288dde 100644
--- a/restore_dir.go
+++ b/restore_dir.go
@@ -39,7 +39,7 @@ func RestoreDir(env *Env, args []string) int {
return 1
}
- if err := backup.RestoreDir(env.Store, id, d); err != nil {
+ if err := backup.RestoreDir(env.Store, id, d, env.Log); err != nil {
errout(err)
return 1
}
diff --git a/snapshot.go b/snapshot.go
index 28b26ff..0b11967 100644
--- a/snapshot.go
+++ b/snapshot.go
@@ -266,7 +266,7 @@ func RestoreSnapshot(env *Env, args []string) int {
return 1
}
- if err := backup.RestoreDir(env.Store, snapshot.Tree, root); err != nil {
+ if err := backup.RestoreDir(env.Store, snapshot.Tree, root, env.Log); err != nil {
errout(err)
return 1
}