more cleaning logics

This commit is contained in:
stefanodvx 2025-04-15 21:32:56 +02:00
parent de628f4911
commit 20245c109b
4 changed files with 28 additions and 1 deletions

View file

@ -481,9 +481,19 @@ func downloadSegments(
errChan := make(chan error, len(segmentURLs))
var errMutex sync.Mutex
var firstErr error
downloadedFiles := make([]string, len(segmentURLs))
defer func() {
if firstErr != nil {
for _, path := range downloadedFiles {
if path != "" {
os.Remove(path)
}
}
}
}()
downloadCtx, cancelDownload := context.WithCancel(ctx)
defer cancelDownload()