diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-10-15 12:03:44 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-10-15 12:03:44 +0200 |
commit | 3ffafd6499f50ea71d1ad1a7ac554f4c4448ed6c (patch) | |
tree | 6caec73906e90cd3e4fbe6592868e979f7d4479e /tar.go | |
parent | 5016267b78261b07ac24190584707bf2745160a8 (diff) | |
download | dna-backup-3ffafd6499f50ea71d1ad1a7ac554f4c4448ed6c.tar.gz dna-backup-3ffafd6499f50ea71d1ad1a7ac554f4c4448ed6c.zip |
add copyright and license notice + remove dead code
Diffstat (limited to 'tar.go')
-rw-r--r-- | tar.go | 43 |
1 files changed, 0 insertions, 43 deletions
@@ -1,43 +0,0 @@ -package main - -import ( - "archive/tar" - "io" - "os" - - "github.com/n-peugnet/dna-backup/logger" - "github.com/n-peugnet/dna-backup/repo" -) - -func streamFilesTar(files []repo.File, stream io.WriteCloser) { - tarStream := tar.NewWriter(stream) - for _, f := range files { - file, err := os.Open(f.Path) - if err != nil { - logger.Error(err) - continue - } - stat, err := file.Stat() - if err != nil { - logger.Errorf("getting stat of file '%s': %s", f.Path, err) - continue - } - hdr, err := tar.FileInfoHeader(stat, "") - if err != nil { - logger.Errorf("creating tar header for file '%s': %s", f.Path, err) - continue - } - if err := tarStream.WriteHeader(hdr); err != nil { - logger.Panicf("writing tar header to stream for file '%s': %s", f.Path, err) - } - if _, err := io.Copy(tarStream, file); err != nil { - logger.Panicf("writing file to stream '%s': %s", f.Path, err) - } - } - if err := tarStream.Close(); err != nil { - logger.Panic("closing tar stream:", err) - } - if err := stream.Close(); err != nil { - logger.Panic("closing stream:", err) - } -} |