Files
godeez/internal/downloader/skip.go
T

38 lines
716 B
Go

package downloader
import (
"context"
"github.com/mathismqn/godeez/internal/fileutil"
"github.com/mathismqn/godeez/internal/store"
)
func (c *Client) shouldSkipDownload(ctx context.Context, trackID, mediaFormat string) (string, bool) {
existing, err := store.GetDownloadInfo(trackID)
if err != nil || existing.Quality != mediaFormat {
return "", false
}
if fileutil.FileExists(existing.Path) {
return existing.Path, true
}
if existing.Hash == "" {
return "", false
}
if err := c.initHashIndex(ctx); err != nil {
return "", false
}
foundPath, ok := c.hashIndex.Find(existing.Hash)
if !ok {
return "", false
}
existing.Path = foundPath
_ = existing.Save()
return foundPath, true
}