mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
fix(backup): calculate file size correctly EE-6439 (#10919)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
bf66b6c5f3
commit
1676fefd97
2 changed files with 22 additions and 14 deletions
|
@ -48,18 +48,6 @@ func TarGzDir(absolutePath string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addToArchive(tarWriter *tar.Writer, pathInArchive string, path string, info os.FileInfo) error {
|
func addToArchive(tarWriter *tar.Writer, pathInArchive string, path string, info os.FileInfo) error {
|
||||||
header, err := tar.FileInfoHeader(info, info.Name())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
header.Name = pathInArchive // use relative paths in archive
|
|
||||||
|
|
||||||
err = tarWriter.WriteHeader(header)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -68,6 +56,26 @@ func addToArchive(tarWriter *tar.Writer, pathInArchive string, path string, info
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stat, err := file.Stat()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
header, err := tar.FileInfoHeader(stat, stat.Name())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
header.Name = pathInArchive // use relative paths in archive
|
||||||
|
|
||||||
|
err = tarWriter.WriteHeader(header)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if stat.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
_, err = io.Copy(tarWriter, file)
|
_, err = io.Copy(tarWriter, file)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -98,7 +106,7 @@ func ExtractTarGz(r io.Reader, outputDirPath string) error {
|
||||||
// skip, dir will be created with a file
|
// skip, dir will be created with a file
|
||||||
case tar.TypeReg:
|
case tar.TypeReg:
|
||||||
p := filepath.Clean(filepath.Join(outputDirPath, header.Name))
|
p := filepath.Clean(filepath.Join(outputDirPath, header.Name))
|
||||||
if err := os.MkdirAll(filepath.Dir(p), 0744); err != nil {
|
if err := os.MkdirAll(filepath.Dir(p), 0o744); err != nil {
|
||||||
return fmt.Errorf("Failed to extract dir %s", filepath.Dir(p))
|
return fmt.Errorf("Failed to extract dir %s", filepath.Dir(p))
|
||||||
}
|
}
|
||||||
outFile, err := os.Create(p)
|
outFile, err := os.Create(p)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const rwxr__r__ os.FileMode = 0744
|
const rwxr__r__ os.FileMode = 0o744
|
||||||
|
|
||||||
var filesToBackup = []string{
|
var filesToBackup = []string{
|
||||||
"certs",
|
"certs",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue