archive: add "none" compression format (MR 25)
This commit is contained in:
@@ -29,6 +29,7 @@ const (
|
|||||||
FormatGzip CompressFormat = "gzip"
|
FormatGzip CompressFormat = "gzip"
|
||||||
FormatLzma CompressFormat = "lzma"
|
FormatLzma CompressFormat = "lzma"
|
||||||
FormatZstd CompressFormat = "zstd"
|
FormatZstd CompressFormat = "zstd"
|
||||||
|
FormatNone CompressFormat = "none"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CompressLevel string
|
type CompressLevel string
|
||||||
@@ -103,6 +104,7 @@ func ExtractFormatLevel(s string) (format CompressFormat, level CompressLevel) {
|
|||||||
case FormatLzma:
|
case FormatLzma:
|
||||||
log.Println("Format lzma doesn't support a compression level, using default settings")
|
log.Println("Format lzma doesn't support a compression level, using default settings")
|
||||||
level = LevelDefault
|
level = LevelDefault
|
||||||
|
case FormatNone:
|
||||||
case FormatZstd:
|
case FormatZstd:
|
||||||
default:
|
default:
|
||||||
log.Print("Unknown or no compression format set, using gzip")
|
log.Print("Unknown or no compression format set, using gzip")
|
||||||
@@ -313,6 +315,8 @@ func (archive *Archive) writeCompressed(path string, mode os.FileMode) (err erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
case FormatNone:
|
||||||
|
compressor = fd
|
||||||
case FormatZstd:
|
case FormatZstd:
|
||||||
level := zstd.SpeedDefault
|
level := zstd.SpeedDefault
|
||||||
switch archive.compress_level {
|
switch archive.compress_level {
|
||||||
|
@@ -238,7 +238,7 @@ func TestExtractFormatLevel(t *testing.T) {
|
|||||||
expectedLevel: LevelBest,
|
expectedLevel: LevelBest,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "none, none",
|
name: "<empty>, <empty>",
|
||||||
in: "",
|
in: "",
|
||||||
expectedFormat: FormatGzip,
|
expectedFormat: FormatGzip,
|
||||||
expectedLevel: LevelDefault,
|
expectedLevel: LevelDefault,
|
||||||
@@ -249,6 +249,12 @@ func TestExtractFormatLevel(t *testing.T) {
|
|||||||
expectedFormat: FormatLzma,
|
expectedFormat: FormatLzma,
|
||||||
expectedLevel: LevelDefault,
|
expectedLevel: LevelDefault,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "none",
|
||||||
|
in: "none",
|
||||||
|
expectedFormat: FormatNone,
|
||||||
|
expectedLevel: LevelDefault,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Reference in New Issue
Block a user