feat: Implement restoring folders

This commit is contained in:
Felix Pojtinger
2021-11-28 16:23:43 +01:00
parent 6d7358db03
commit 1c491e6540
2 changed files with 5 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ var moveCmd = &cobra.Command{
return err
}
// Append deletion headers to the tape/tar file
// Append move headers to the tape/tar file
for _, dbhdr := range headersToMove {
hdr, err := converters.DBHeaderToTarHeader(dbhdr)
if err != nil {

View File

@@ -82,6 +82,10 @@ var restoreCmd = &cobra.Command{
dst = filepath.Base(hdr.Name)
}
if hdr.Typeflag == tar.TypeDir {
return os.MkdirAll(dst, hdr.FileInfo().Mode())
}
dstFile, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE, hdr.FileInfo().Mode())
if err != nil {
return err