From 287b286940db8fabb8ae020f3fc6b18b14433818 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Wed, 18 Nov 2020 18:44:25 -0700 Subject: [PATCH] Oh, that's why it was done like that --- server/backup/archiver.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/backup/archiver.go b/server/backup/archiver.go index 426063a..dd7dca5 100644 --- a/server/backup/archiver.go +++ b/server/backup/archiver.go @@ -109,6 +109,7 @@ func (a *Archive) addToArchive(p string, w *tar.Writer) error { if err != nil { return errors.WithStackIf(err) } + header.Name = strings.TrimPrefix(p, a.TrimPrefix) // These actions must occur sequentially, even if this function is called multiple // in parallel. You'll get some nasty panic's otherwise. @@ -120,7 +121,7 @@ func (a *Archive) addToArchive(p string, w *tar.Writer) error { } buf := make([]byte, 4*1024) - if _, err := io.CopyBuffer(w, f, buf); err != nil { + if _, err := io.CopyBuffer(w, io.LimitReader(f, header.Size), buf); err != nil { return errors.WithStackIf(err) }