Browse Source

尝试修复 zip 解压中文文件名的问题

Signed-off-by: allan716 <[email protected]>
allan716 2 years ago
parent
commit
f8a0194f1a
1 changed files with 7 additions and 0 deletions
  1. 7 0
      pkg/archive_helper/unarchiveFile.go

+ 7 - 0
pkg/archive_helper/unarchiveFile.go

@@ -10,6 +10,7 @@ import (
 	"os"
 	"path/filepath"
 	"strings"
+	"unicode/utf8"
 
 	"github.com/allanpk716/ChineseSubFinder/pkg"
 
@@ -104,6 +105,12 @@ func UnArchiveFile(fileFullPath, desRootPath string) error {
 				if err != nil {
 					return err
 				}
+			} else {
+				// 需要检测文件名是否是乱码
+				err := processOneFile(f, !utf8.ValidString(f.Name()), desRootPath)
+				if err != nil {
+					return err
+				}
 			}
 			return nil
 		})