(goctl)fix code_ql (#4009)

This commit is contained in:
kesonan 2024-03-17 10:21:36 +08:00 committed by GitHub
parent bbce95e7e1
commit 3e794cf991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,10 +16,15 @@ func Unpacking(name, destPath string, mapper func(f *zip.File) bool) error {
}
defer r.Close()
destAbsPath, err := filepath.Abs(destPath)
if err != nil {
return err
}
for _, file := range r.File {
ok := mapper(file)
if ok {
err = fileCopy(file, destPath)
err = fileCopy(file, destAbsPath)
if err != nil {
return err
}
@ -34,7 +39,12 @@ func fileCopy(file *zip.File, destPath string) error {
return err
}
defer rc.Close()
filename := filepath.Join(destPath, filepath.Base(file.Name))
abs, err := filepath.Abs(file.Name)
if err != nil {
return err
}
filename := filepath.Join(destPath, filepath.Base(abs))
dir := filepath.Dir(filename)
err = pathx.MkdirIfNotExist(dir)
if err != nil {