{backup,snapshort}: Improve behaviour
This commit improves the behaviour of 'backup' and 'snapshot' by treating symbolic links properly, as well as writes proper reports.
This commit is contained in:
parent
94263174cf
commit
a4f91ae7cf
7 changed files with 298 additions and 91 deletions
|
|
@ -31,7 +31,7 @@ func Package(dst, src string, onCopy func(rel string, src string)) (count int64,
|
|||
defer tarHandle.Close()
|
||||
|
||||
// and walk through it!
|
||||
err = filepath.Walk(src, func(path string, info fs.FileInfo, err error) error {
|
||||
err = filepath.WalkDir(src, func(path string, entry fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -43,10 +43,17 @@ func Package(dst, src string, onCopy func(rel string, src string)) (count int64,
|
|||
return err
|
||||
}
|
||||
|
||||
// call the oncopy!
|
||||
if onCopy != nil {
|
||||
onCopy(relpath, path)
|
||||
}
|
||||
|
||||
// read mode etc
|
||||
info, err := entry.Info()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create a file info header!
|
||||
tInfo, err := tar.FileInfoHeader(info, relpath)
|
||||
if err != nil {
|
||||
|
|
@ -60,7 +67,7 @@ func Package(dst, src string, onCopy func(rel string, src string)) (count int64,
|
|||
}
|
||||
|
||||
// a directory => no more writing required
|
||||
if info.IsDir() {
|
||||
if entry.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue