Skip to content

Commit

Permalink
roblox/bootstrapper: move util md5 verify internal
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Jan 30, 2024
1 parent 0b3ac53 commit a9b588a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
25 changes: 23 additions & 2 deletions roblox/bootstrapper/package.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package bootstrapper

import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"log"
"os"

"github.com/vinegarhq/vinegar/util"
)
Expand All @@ -21,8 +25,20 @@ type Packages []Package
func (p *Package) Verify(src string) error {
log.Printf("Verifying Package %s (%s)", p.Name, p.Checksum)

if err := util.VerifyFileMD5(src, p.Checksum); err != nil {
return fmt.Errorf("verify package %s: %w", p.Name, err)
f, err := os.Open(src)
if err != nil {
return err
}
defer f.Close()

h := md5.New()
if _, err := io.Copy(h, f); err != nil {
return err
}
fsum := hex.EncodeToString(h.Sum(nil))

if p.Checksum != fsum {
return fmt.Errorf("package %s (%s) is corrupted, please re-download or delete package", p.Name, src)
}

return nil
Expand Down Expand Up @@ -64,3 +80,8 @@ func (p *Package) Extract(src, dest string) error {
log.Printf("Extracted Package %s (%s): %s", p.Name, p.Checksum, dest)
return nil
}

func verifyFileMD5(name string, sum string) error {

return nil
}
30 changes: 0 additions & 30 deletions util/md5.go

This file was deleted.

0 comments on commit a9b588a

Please sign in to comment.