fix: use formatGNU tar

https://github.com/pterodactyl/panel/issues/4365
This commit is contained in:
Shugen 2022-09-08 11:39:00 +08:00
parent 83861a6dec
commit be8a7638c1

View File

@ -8,6 +8,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"time"
"emperror.dev/errors" "emperror.dev/errors"
"github.com/apex/log" "github.com/apex/log"
@ -183,6 +184,14 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error {
// Get the tar FileInfoHeader in order to add the file to the archive. // Get the tar FileInfoHeader in order to add the file to the archive.
header, err := tar.FileInfoHeader(s, filepath.ToSlash(target)) header, err := tar.FileInfoHeader(s, filepath.ToSlash(target))
// set to format gnu so 7-zip can read Chinese Filename
header.Format = tar.FormatGNU
// temp workaround for golang write accesstime and changetime into gnu_headers prefix.
header.AccessTime = time.Time{}
header.ChangeTime = time.Time{}
if err != nil { if err != nil {
return errors.WrapIff(err, "failed to get tar#FileInfoHeader for '%s'", rp) return errors.WrapIff(err, "failed to get tar#FileInfoHeader for '%s'", rp)
} }