more cleaning logics
This commit is contained in:
parent
de628f4911
commit
20245c109b
4 changed files with 28 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -110,3 +110,11 @@ func CheckFFmpeg() bool {
|
|||
_, err := exec.LookPath("ffmpeg")
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func ClearDownlods() {
|
||||
downloadsDir := os.Getenv("DOWNLOADS_DIR")
|
||||
if downloadsDir == "" {
|
||||
downloadsDir = "downloads"
|
||||
}
|
||||
os.RemoveAll(downloadsDir)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue