If dbstream then stream backup instead of reading into memory

This commit is contained in:
Bel LaPointe
2021-02-07 12:57:25 -06:00
parent 6baa938b22
commit 39ddc93e2f

View File

@@ -82,12 +82,21 @@ func (lastN *LastN) Push() error {
if err != nil {
return fmt.Errorf("%v: %s", err, out)
}
key := path.Base(archive)
if storeStream, ok := store.(storage.DBStream); ok {
f, err := os.Open(archive)
if err != nil {
return err
}
defer f.Close()
return storeStream.SetStream(key, f, lastN.conf.Ns)
}
b, err := ioutil.ReadFile(archive)
if err != nil {
return err
}
log.Println("Created backup", path.Base(archive))
return store.Set(path.Base(archive), b, lastN.conf.Ns)
log.Println("Created backup", key)
return store.Set(key, b, lastN.conf.Ns)
}
func (lastN *LastN) Clean() error {