mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
(goctl)fix code_ql (#4009)
This commit is contained in:
parent
bbce95e7e1
commit
3e794cf991
@ -16,10 +16,15 @@ func Unpacking(name, destPath string, mapper func(f *zip.File) bool) error {
|
|||||||
}
|
}
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
|
destAbsPath, err := filepath.Abs(destPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, file := range r.File {
|
for _, file := range r.File {
|
||||||
ok := mapper(file)
|
ok := mapper(file)
|
||||||
if ok {
|
if ok {
|
||||||
err = fileCopy(file, destPath)
|
err = fileCopy(file, destAbsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -34,7 +39,12 @@ func fileCopy(file *zip.File, destPath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer rc.Close()
|
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)
|
dir := filepath.Dir(filename)
|
||||||
err = pathx.MkdirIfNotExist(dir)
|
err = pathx.MkdirIfNotExist(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user