backups: add an option to change gzip compression level (#128)

This commit is contained in:
PotatoMaaan
2022-09-26 02:47:09 +02:00
committed by GitHub
parent c736c24118
commit c686992e85
2 changed files with 23 additions and 1 deletions

View File

@@ -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()