Skip to content

Commit 74866af

Browse files
committed
swupd: add XZ compression for fullfiles
Signed-off-by: Caio Marcelo de Oliveira Filho <[email protected]>
1 parent 712c89f commit 74866af

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

swupd/fullfiles.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"path/filepath"
1313
"sync"
1414

15-
_ "github.com/ulikunitz/xz"
15+
"github.com/ulikunitz/xz"
1616
)
1717

1818
const DebugFullfiles = false
@@ -25,6 +25,7 @@ var fullfileCompressors = []struct {
2525
ExternalTarExtraArg string
2626
}{
2727
{"gzip", compressGzip, ""},
28+
{"xz", compressXZ, ""},
2829
{"external-tar-bzip2", nil, "--bzip2"},
2930
{"external-tar-gzip", nil, "--gzip"},
3031
{"external-tar-xz", nil, "--xz"},
@@ -345,3 +346,15 @@ func compressGzip(dst io.Writer, src io.Reader) error {
345346
}
346347
return gw.Close()
347348
}
349+
350+
func compressXZ(dst io.Writer, src io.Reader) error {
351+
xw, err := xz.NewWriter(dst)
352+
if err != nil {
353+
return err
354+
}
355+
_, err = io.Copy(xw, src)
356+
if err != nil {
357+
return err
358+
}
359+
return xw.Close()
360+
}

0 commit comments

Comments
 (0)