backups: add an option to change gzip compression level (#128)
This commit is contained in:
@@ -62,8 +62,21 @@ func (a *Archive) Create(dst string) error {
|
||||
writer = f
|
||||
}
|
||||
|
||||
// The default compression level is BestSpeed
|
||||
var cl = pgzip.BestSpeed
|
||||
|
||||
// Choose which compression level to use based on the compression_level configuration option
|
||||
switch config.Get().System.Backups.CompressionLevel {
|
||||
case "none":
|
||||
cl = pgzip.NoCompression
|
||||
case "best_speed":
|
||||
cl = pgzip.BestSpeed
|
||||
case "best_compression":
|
||||
cl = pgzip.BestCompression
|
||||
}
|
||||
|
||||
// Create a new gzip writer around the file.
|
||||
gw, _ := pgzip.NewWriterLevel(writer, pgzip.BestSpeed)
|
||||
gw, _ := pgzip.NewWriterLevel(writer, cl)
|
||||
_ = gw.SetConcurrency(1<<20, 1)
|
||||
defer gw.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user