internal/download: add DownloadFileFromKnownURL

This commit is contained in:
Felix Lange 2025-05-14 10:18:08 +02:00
parent 4aa7b8d029
commit 0abafba918

View file

@ -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 {