From 39ddc93e2f7ad70c6b1092fe4226b85c074c0cba Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Sun, 7 Feb 2021 12:57:25 -0600 Subject: [PATCH] If dbstream then stream backup instead of reading into memory --- lastn/lastn.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lastn/lastn.go b/lastn/lastn.go index 4e1308e..3e5839f 100755 --- a/lastn/lastn.go +++ b/lastn/lastn.go @@ -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 {