Refactored downloader

This commit is contained in:
2021-12-22 01:22:33 +01:00
parent 4b9583b08f
commit 23ca1168df
21 changed files with 544 additions and 177 deletions

View File

@@ -3,9 +3,8 @@ package _default
import (
"downloader/internal/core/entities"
"downloader/internal/core/ports/download_request"
"downloader/internal/core/ports/downloader"
"downloader/internal/core/services/download"
"fmt"
"downloader/internal/core/services/downloader"
"go.uber.org/zap"
)
@@ -26,10 +25,7 @@ func (l localBackgroundService) Run(download *entities.Download) error {
download.Status = "started"
_ = l.repository.Update(download)
err := l.downloader.Download(download.Link, func(progress string) {
download.Status = fmt.Sprintf("in-progress: %s", progress)
_ = l.repository.Update(download)
})
err := l.downloader.Download(download.Link, download.ID)
download.Status = "done"
if err != nil {