unzip 버그 수정 - 백슬래시 처리 추가
This commit is contained in:
@ -55,6 +55,9 @@ func download(dir string, urlpath string, accessToken string) (string, error) {
|
|||||||
return filepath.ToSlash(out.Name()), nil
|
return filepath.ToSlash(out.Name()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UnzipTest(fname string) error {
|
||||||
|
return unzip(fname)
|
||||||
|
}
|
||||||
func unzip(fname string) error {
|
func unzip(fname string) error {
|
||||||
archive, err := zip.OpenReader(fname)
|
archive, err := zip.OpenReader(fname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -75,10 +78,12 @@ func unzip(fname string) error {
|
|||||||
name = f.Name
|
name = f.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = strings.ReplaceAll(name, `\`, "/")
|
||||||
filePath := path.Join(verpath, name)
|
filePath := path.Join(verpath, name)
|
||||||
|
if f.FileInfo().IsDir() || strings.HasSuffix(f.FileInfo().Name(), `\`) {
|
||||||
if f.FileInfo().IsDir() {
|
if err = os.MkdirAll(filePath, 0775); err != nil {
|
||||||
os.MkdirAll(filePath, 0775)
|
return err
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user