refactor: consolidate download domain into download package

This commit is contained in:
Mathis Maquenne
2026-08-05 11:46:10 +02:00
parent dbb808f371
commit 5c95554855
14 changed files with 314 additions and 300 deletions
+36
View File
@@ -0,0 +1,36 @@
package download
import (
"context"
"github.com/mathismqn/godeez/internal/fsutil"
)
func (d *Downloader) shouldSkipDownload(ctx context.Context, trackID, mediaFormat string) (string, bool) {
existing, err := d.store.DownloadInfo(trackID)
if err != nil || existing.Quality != mediaFormat {
return "", false
}
if fsutil.Exists(existing.Path) {
return existing.Path, true
}
if existing.Hash == "" {
return "", false
}
if err := d.initHashIndex(ctx); err != nil {
return "", false
}
foundPath, ok := d.hashIndex.find(existing.Hash)
if !ok {
return "", false
}
existing.Path = foundPath
_ = d.store.PutDownloadInfo(existing)
return foundPath, true
}