forked from TrueCloudLab/frostfs-node
[#1060] blobstor: allow to disable compression based on content-type
For some data compression makes little sense, as it is already compressed. This commit allows to leave such data unchanged based on `Content-Type` attribute. Currently exact, prefix and suffix matching are supported. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
0f1eb743af
commit
0d969d7a06
11 changed files with 133 additions and 8 deletions
|
@ -70,6 +70,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.Equal(t, "tmp/0/blob", blob.Path())
|
||||
require.EqualValues(t, 0644, blob.Perm())
|
||||
require.Equal(t, true, blob.Compress())
|
||||
require.Equal(t, []string{"audio/*", "video/*"}, blob.UncompressableContentTypes())
|
||||
require.EqualValues(t, 5, blob.ShallowDepth())
|
||||
require.EqualValues(t, 102400, blob.SmallSizeLimit())
|
||||
|
||||
|
@ -99,6 +100,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.Equal(t, "tmp/1/blob", blob.Path())
|
||||
require.EqualValues(t, 0644, blob.Perm())
|
||||
require.Equal(t, false, blob.Compress())
|
||||
require.Equal(t, []string(nil), blob.UncompressableContentTypes())
|
||||
require.EqualValues(t, 5, blob.ShallowDepth())
|
||||
require.EqualValues(t, 102400, blob.SmallSizeLimit())
|
||||
|
||||
|
|
|
@ -88,6 +88,15 @@ func (x *Config) Compress() bool {
|
|||
)
|
||||
}
|
||||
|
||||
// UncompressableContentTypes returns value of "compress_skip_content_types" config parameter.
|
||||
//
|
||||
// Returns nil if a value is missing or is invalid.
|
||||
func (x *Config) UncompressableContentTypes() []string {
|
||||
return config.StringSliceSafe(
|
||||
(*config.Config)(x),
|
||||
"compression_exclude_content_types")
|
||||
}
|
||||
|
||||
// SmallSizeLimit returns value of "small_object_size" config parameter.
|
||||
//
|
||||
// Returns SmallSizeLimitDefault if value is not a positive number.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue