From a64981930b3e08629752490b2fc31b85e1cc2dce Mon Sep 17 00:00:00 2001 From: bytedream Date: Tue, 2 Aug 2022 12:07:43 +0200 Subject: [PATCH] Add option to change temp dir --- cli/commands/archive/archive.go | 7 +++++++ cli/commands/download/download.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/cli/commands/archive/archive.go b/cli/commands/archive/archive.go index 8e09f5e..b2be970 100644 --- a/cli/commands/archive/archive.go +++ b/cli/commands/archive/archive.go @@ -29,6 +29,7 @@ var ( archiveDirectoryFlag string archiveOutputFlag string + archiveTempDirFlag string archiveMergeFlag string @@ -146,6 +147,10 @@ func init() { "\t{fps} » Frame Rate of the video\n"+ "\t{audio} » Audio locale of the video\n"+ "\t{subtitle} » Subtitle locale of the video") + Cmd.Flags().StringVar(&archiveTempDirFlag, + "temp", + os.TempDir(), + "Directory to store temporary files in") Cmd.Flags().StringVarP(&archiveMergeFlag, "merge", @@ -315,6 +320,8 @@ func archiveInfo(info utils.FormatInformation, writeCloser io.WriteCloser, filen } return nil }) + tmp, _ := os.MkdirTemp(archiveTempDirFlag, "crunchy_") + downloader.TempDir = tmp sig := make(chan os.Signal, 1) signal.Notify(sig, os.Interrupt) diff --git a/cli/commands/download/download.go b/cli/commands/download/download.go index 2976e2d..60e975e 100644 --- a/cli/commands/download/download.go +++ b/cli/commands/download/download.go @@ -25,6 +25,7 @@ var ( downloadDirectoryFlag string downloadOutputFlag string + downloadTempDirFlag string downloadResolutionFlag string @@ -111,6 +112,10 @@ func init() { "\t{fps} » Frame Rate of the video\n"+ "\t{audio} » Audio locale of the video\n"+ "\t{subtitle} » Subtitle locale of the video") + Cmd.Flags().StringVar(&downloadTempDirFlag, + "temp", + os.TempDir(), + "Directory to store temporary files in") Cmd.Flags().StringVarP(&downloadResolutionFlag, "resolution", @@ -230,6 +235,8 @@ func downloadInfo(info utils.FormatInformation, file *os.File) error { } return nil }) + tmp, _ := os.MkdirTemp(downloadTempDirFlag, "crunchy_") + downloader.TempDir = tmp if utils.HasFFmpeg() { downloader.FFmpegOpts = make([]string, 0) }