1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-03-18 05:37:49 +02:00

registered a custom Deflate compressor to speedup the backups generation

This commit is contained in:
Gani Georgiev 2023-09-01 13:46:51 +03:00
parent 78e70bd52b
commit 322508f6d1
2 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,9 @@
@hourly - "0 * * * *"
```
- Registered a custom Deflate compressor to speedup the backups generation.
_Based on several local tests, `pb_data` of ~500MB (from which ~350MB+ are several hundred small files) results in a ~280MB zip generated for ~11s (previously was ~250MB but for ~35s)._
- (@todo update docs examples) To minimize the footguns with `Dao.FindFirstRecordByFilter()` and `Dao.FindRecordsByFilter()`, the functions now supports an optional placeholder params argument that is safe to be populated with untrusted user input.
The placeholders are in the same format as when binding regular SQL parameters.
```go

View File

@ -2,6 +2,7 @@ package archive
import (
"archive/zip"
"compress/flate"
"io"
"io/fs"
"os"
@ -27,6 +28,11 @@ func Create(src string, dest string, skipPaths ...string) error {
zw := zip.NewWriter(zf)
defer zw.Close()
// register a custom Deflate compressor
zw.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, flate.BestSpeed)
})
if err := zipAddFS(zw, os.DirFS(src), skipPaths...); err != nil {
// try to cleanup at least the created zip file
os.Remove(dest)