FIX: Fix bug check diff type

This commit is contained in:
2025-08-26 09:58:30 +07:00
parent 6b222bfa70
commit a021658fa9
4 changed files with 19 additions and 22 deletions

View File

@@ -87,19 +87,6 @@ export default function DiffPage() {
setDiffDir('')
return
}
const [isOk, validType, errorType] = await DiffService.CheckTypeHDiff(basePath)
if (!isOk) {
toast.error(errorType)
setDiffCheckResult('error')
setDiffDir('')
return
}
if (validType == "") {
toast.error('Not valid file type')
setDiffCheckResult('error')
setDiffDir('')
return
}
setDiffDir(basePath)
setDiffCheckResult('success')
} else {
@@ -134,8 +121,6 @@ export default function DiffPage() {
}
setProgressUpdate(1)
if (validType === 'hdiffmap.json') {
setStageType('Version Validate')
setProgressUpdate(0)

View File

@@ -18,16 +18,16 @@ import (
type DiffService struct{}
func (h *DiffService) CheckTypeHDiff(patchPath string) (bool, string, string) {
if ok, err := sevenzip.IsFileIn7z(patchPath, "manifest"); err == nil && ok {
return true, "manifest", ""
}
if ok, err := sevenzip.IsFileIn7z(patchPath, "hdifffiles.txt"); err == nil && ok {
return true, "hdifffiles.txt", ""
}
if ok, err := sevenzip.IsFileIn7z(patchPath, "hdiffmap.json"); err == nil && ok {
return true, "hdiffmap.json", ""
}
if ok, err := sevenzip.IsFileIn7z(patchPath, "manifest"); err == nil && ok {
return true, "manifest", ""
}
return false, "", "not found hdifffiles.txt or hdiffmap.json"
}
@@ -155,9 +155,12 @@ func (h *DiffService) DeleteFiles(gamePath string) (bool, string) {
}
if err := scanner.Err(); err != nil {
file.Close()
return false, "no delete files exist"
}
file.Close()
for i, file := range deleteFiles {
os.Remove(filepath.Join(gamePath, file))
application.Get().Event.Emit("diff:progress", map[string]int{"progress": i, "maxProgress": len(deleteFiles)})

View File

@@ -10,7 +10,7 @@ const ProxyZipFile = "64bit.zip"
const LauncherFile = "firefly-launcher.exe"
const TempUrl = "./temp"
const CurrentLauncherVersion = "1.5.0"
const CurrentLauncherVersion = "1.5.1"
type ToolFile string

View File

@@ -21,9 +21,18 @@ func IsFileIn7z(archivePath, fileInside string) (bool, error) {
lines := strings.Split(out.String(), "\n")
for _, line := range lines {
if strings.Contains(line, fileInside) {
return true, nil
line = strings.TrimSpace(line)
if line == "" {
continue
}
parts := strings.Fields(line)
if len(parts) > 0 {
path := parts[len(parts)-1]
if path == fileInside {
return true, nil
}
}
}
return false, fmt.Errorf("%s not found in %s", fileInside, archivePath)