UPDATE: Add precheck version hdiff, support another hdiff

This commit is contained in:
2025-08-29 21:13:10 +07:00
parent a4de02bc18
commit d58e76d821
12 changed files with 212 additions and 154 deletions

View File

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

View File

@@ -10,10 +10,11 @@ import (
)
type BinaryVersion struct {
Name string
Name string
Major int
Minor int
Patch int
Data []byte
}
func ParseBinaryVersion(path string) (*BinaryVersion, error) {
@@ -28,7 +29,7 @@ func ParseBinaryVersion(path string) (*BinaryVersion, error) {
if lastDash == -1 {
return nil, errors.New("no dash found in version string")
}
secondLastDash := strings.LastIndex(content[:lastDash], "-")
if secondLastDash == -1 {
return nil, errors.New("only one dash found in version string")
@@ -64,17 +65,18 @@ func ParseBinaryVersion(path string) (*BinaryVersion, error) {
}
}
binaryVersion.Data = data
return &binaryVersion, nil
}
func (v *BinaryVersion) String() string {
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
return fmt.Sprintf("%s-%d.%d.%d", v.Name, v.Major, v.Minor, v.Patch)
}
func (v BinaryVersion) ToInt() int {
return v.Major*100 + v.Minor*10 + v.Patch
}
func (v BinaryVersion) Subtract(other BinaryVersion) int {
func (v BinaryVersion) Subtract(other *BinaryVersion) int {
return v.ToInt() - other.ToInt()
}

View File

@@ -67,7 +67,7 @@ func check(relPath string, expectedSize int64, expectedMD5, base string) error {
fullPath, expectedSize, info.Size())
}
md5Hash, err := fileMD5(fullPath)
md5Hash, err := FileMD5(fullPath)
if err != nil {
return fmt.Errorf("error reading %s: %w", fullPath, err)
}
@@ -80,7 +80,7 @@ func check(relPath string, expectedSize int64, expectedMD5, base string) error {
return nil
}
func fileMD5(path string) (string, error) {
func FileMD5(path string) (string, error) {
f, err := os.Open(path)
if err != nil {
return "", err