1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Add "none" compression type (#457)

* Add "none" compression type

* Add "none" compression to docs

* Use passThroughWriteCloser for "none" compression

* Add test for none compression

---------

Co-authored-by: Frederik Ring <frederik.ring@gmail.com>
This commit is contained in:
J. Zebedee
2024-08-11 03:11:09 -05:00
committed by GitHub
parent 336e12f874
commit f97ce11734
6 changed files with 70 additions and 5 deletions

View File

@@ -93,6 +93,8 @@ func compress(paths []string, outFilePath, algo string, concurrency int) error {
func getCompressionWriter(file *os.File, algo string, concurrency int) (io.WriteCloser, error) {
switch algo {
case "none":
return &passThroughWriteCloser{file}, nil
case "gz":
w, err := pgzip.NewWriterLevel(file, 5)
if err != nil {
@@ -165,3 +167,15 @@ func writeTarball(path string, tarWriter *tar.Writer, prefix string) error {
return nil
}
type passThroughWriteCloser struct {
target io.WriteCloser
}
func (p *passThroughWriteCloser) Write(b []byte) (int, error) {
return p.target.Write(b)
}
func (p *passThroughWriteCloser) Close() error {
return nil
}