Skip to content

Commit

Permalink
mod: It is allowed not to provide checksum, but a warning will be issued
Browse files Browse the repository at this point in the history
  • Loading branch information
aooohan committed Jan 16, 2024
1 parent 523f027 commit 74b9fe4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/sdk/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"github.com/pterm/pterm"
"os"
)

Expand All @@ -48,9 +49,17 @@ func (c *Checksum) verify(path string) bool {
} else if c.Type == "md5" {
hashValue := md5.Sum(fileData)
hash = hashValue[:]
} else if c.Type == "none" {
pterm.Printf("%s: Checksum is not provided, skip verify...\n", pterm.LightYellow("WARNING"))
return true
} else {
return false
}
checksum := hex.EncodeToString(hash)
return checksum == c.Value
}

var NoneChecksum = &Checksum{
Value: "",
Type: "none",
}
2 changes: 1 addition & 1 deletion internal/sdk/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (l *LuaPlugin) Checksum(table *lua.LTable) (*Checksum, error) {
checksum.Value = sha512.String()
checksum.Type = "sha512"
} else {
return nil, fmt.Errorf("checksum not found")
return NoneChecksum, nil
}
return checksum, nil
}
Expand Down

0 comments on commit 74b9fe4

Please sign in to comment.