mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
incusd/storage/generic: Use proper custom volume size for backup if possible
Signed-off-by: Benjamin Somers <benjamin.somers@imt-atlantique.fr>
This commit is contained in:
@@ -25,6 +25,6 @@ func (crw *InstanceRawWriter) WriteFile(name string, srcPath string, fi os.FileI
|
||||
|
||||
// WriteFileFromReader streams a file into the target file.
|
||||
func (crw *InstanceRawWriter) WriteFileFromReader(src io.Reader, fi os.FileInfo) error {
|
||||
_, err := io.Copy(crw.rawWriter, src)
|
||||
_, err := io.CopyN(crw.rawWriter, src, fi.Size())
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -602,9 +603,15 @@ func genericVFSBackupVolume(d Driver, vol Volume, writer instancewriter.Instance
|
||||
|
||||
defer func() { _ = from.Close() }()
|
||||
|
||||
var fileSize int64
|
||||
fileSize, err = strconv.ParseInt(vol.config["size"], 10, 64)
|
||||
if err != nil {
|
||||
fileSize = blockDiskSize
|
||||
}
|
||||
|
||||
fi := instancewriter.FileInfo{
|
||||
FileName: name,
|
||||
FileSize: blockDiskSize,
|
||||
FileSize: fileSize,
|
||||
FileMode: 0o600,
|
||||
FileModTime: time.Now(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user