fixed non completing downloads after v4

This commit is contained in:
marcopiovanello
2026-07-14 10:17:58 +02:00
parent 143cc28a97
commit f40ad8da78
8 changed files with 47 additions and 126 deletions
+10 -8
View File
@@ -38,14 +38,14 @@ func buildFilename(o *internal.DownloadOutput) {
)
}
func produceLogs(r io.Reader, logs chan<- []byte) {
go func() {
scanner := bufio.NewScanner(r)
func produceLogs(r io.Reader, logs chan<- []byte) error {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
logs <- scanner.Bytes()
}
}()
for scanner.Scan() {
logs <- scanner.Bytes()
}
return scanner.Err()
}
func consumeLogs(ctx context.Context, logs <-chan []byte, c LogConsumer, d Downloader) {
@@ -63,7 +63,7 @@ func consumeLogs(ctx context.Context, logs <-chan []byte, c LogConsumer, d Downl
}
}
func printYtDlpErrors(stdout io.Reader, shortId, url string) {
func printYtDlpErrors(stdout io.Reader, shortId, url string) error {
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
@@ -73,4 +73,6 @@ func printYtDlpErrors(stdout io.Reader, shortId, url string) {
slog.String("err", scanner.Text()),
)
}
return scanner.Err()
}