Attempt to fix 'archive/tar: write too long' error when creating a backup

This commit is contained in:
Matthew Penner 2020-11-18 16:30:34 -07:00
parent 30ec6dc78d
commit 1d0e85cf55

View File

@ -105,13 +105,9 @@ func (a *Archive) addToArchive(p string, w *tar.Writer) error {
return errors.WithStackIf(err) return errors.WithStackIf(err)
} }
header := &tar.Header{ header, err := tar.FileInfoHeader(s, strings.TrimPrefix(p, a.TrimPrefix))
// Trim the long server path from the name of the file so that the resulting if err != nil {
// archive is exactly how the user would see it in the panel file manager. return errors.WithStackIf(err)
Name: strings.TrimPrefix(p, a.TrimPrefix),
Size: s.Size(),
Mode: int64(s.Mode()),
ModTime: s.ModTime(),
} }
// These actions must occur sequentially, even if this function is called multiple // These actions must occur sequentially, even if this function is called multiple