fix: add download cancel via context and update progressbar

This commit is contained in:
2025-01-26 16:33:00 +03:00
parent dc1fac29d5
commit bba1ed52c5
11 changed files with 433 additions and 157 deletions

View File

@ -134,7 +134,7 @@ type Manifest struct {
type Downloader interface {
Name() string
MatchURL(string) bool
Download(Options) (Type, string, error)
Download(context.Context, Options) (Type, string, error)
}
// Интерфейс UpdatingDownloader расширяет Downloader методом Update
@ -157,7 +157,7 @@ func Download(ctx context.Context, opts Options) (err error) {
d := getDownloader(opts.URL)
if opts.CacheDisabled {
_, _, err = d.Download(opts)
_, _, err = d.Download(ctx, opts)
return err
}
@ -226,7 +226,7 @@ func Download(ctx context.Context, opts Options) (err error) {
return err
}
t, name, err := d.Download(Options{
t, name, err := d.Download(ctx, Options{
Hash: opts.Hash,
HashAlgorithm: opts.HashAlgorithm,
Name: opts.Name,