Skip to content

Commit 37a72c0

Browse files
Spitfireapstgraber
authored andcommitted
shared/archive: Added LZ4 support
Signed-off-by: Adrien P <[email protected]>
1 parent d9336ba commit 37a72c0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

shared/archive/detect.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func DetectCompressionFile(f io.Reader) ([]string, string, []string, error) {
2929
// lzma - 6 bytes, { [0x000, 0xE0], '7', 'z', 'X', 'Z', 0x00 } -
3030
// xz - 6 bytes, header format { 0xFD, '7', 'z', 'X', 'Z', 0x00 }
3131
// tar - 263 bytes, trying to get ustar from 257 - 262
32+
// lz4 - 4 bytes 0x04 0x22 0x4d 0x18, magic number
3233
header := make([]byte, 263)
3334
_, err := f.Read(header)
3435
if err != nil {
@@ -56,6 +57,8 @@ func DetectCompressionFile(f io.Reader) ([]string, string, []string, error) {
5657
return []string{""}, ".vmdk", []string{"qemu-img", "convert", "-O", "raw"}, nil
5758
case bytes.Equal(header[0:4], []byte{0x28, 0xb5, 0x2f, 0xfd}):
5859
return []string{"--zstd", "-xf"}, ".tar.zst", []string{"zstd", "-d"}, nil
60+
case bytes.Equal(header[0:4], []byte{0x04, 0x22, 0x4d, 0x18}):
61+
return []string{"-Ilz4", "-xf"}, ".tar.lz4", []string{"lz4", "-d"}, nil
5962
default:
6063
return nil, "", nil, fmt.Errorf("Unsupported compression")
6164
}

0 commit comments

Comments
 (0)