mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
internal/download: add DownloadFileFromKnownURL
This commit is contained in:
parent
4aa7b8d029
commit
0abafba918
1 changed files with 10 additions and 0 deletions
|
|
@ -147,6 +147,16 @@ func (db *ChecksumDB) Verify(path string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DownloadFileFromKnownURL downloads a file from the URL defined in the checksum database.
|
||||||
|
func (db *ChecksumDB) DownloadFileFromKnownURL(dstPath string) error {
|
||||||
|
base := filepath.Base(dstPath)
|
||||||
|
url, err := db.FindURL(base)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return db.DownloadFile(url, dstPath)
|
||||||
|
}
|
||||||
|
|
||||||
// DownloadFile downloads a file and verifies its checksum.
|
// DownloadFile downloads a file and verifies its checksum.
|
||||||
func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
||||||
if err := db.Verify(dstPath); err == nil {
|
if err := db.Verify(dstPath); err == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue