Skip to content

Commit b812d9f

Browse files
committed
Ask to delete temp dir after av1an ran
1 parent 406fd9b commit b812d9f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ff-utils-winforms/UI/Tasks/Av1an.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
5151
string inPath = "";
5252
string outPath = "";
5353
string timestamp = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();
54+
string tempDir = "";
5455

5556
try
5657
{
@@ -112,7 +113,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
112113
}
113114

114115
string tempDirName = !string.IsNullOrWhiteSpace(overrideTempDir) ? overrideTempDir : timestamp;
115-
string tempDir = Path.Combine(Paths.GetAv1anTempPath(), tempDirName);
116+
tempDir = Path.Combine(Paths.GetAv1anTempPath(), tempDirName);
116117
AvProcess.lastTempDirAv1an = tempDir;
117118
string tmp = $"--temp {tempDir.Wrap()}";
118119
Directory.CreateDirectory(tempDir);
@@ -148,6 +149,8 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
148149
await AvProcess.RunAv1an(args, AvProcess.LogMode.OnlyLastLine, true);
149150

150151
Program.mainForm.SetWorking(false);
152+
153+
AskDeleteTempFolder(tempDir);
151154
}
152155

153156
private static string GetScDownscaleArg ()

ff-utils-winforms/UI/Tasks/Av1anUi.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,13 @@ public static Fraction GetUiFps()
324324

325325
public static void AskDeleteTempFolder (string dir)
326326
{
327-
DialogResult dialog = MessageBox.Show($"Do you want to keep the temporary folder of this video for resuming?", "Keep temp folder?", MessageBoxButtons.YesNo);
327+
if (string.IsNullOrWhiteSpace(dir))
328+
return;
329+
330+
var dirSize = IoUtils.GetDirSize(dir, true);
331+
DialogResult dialog = MessageBox.Show($"Do you want to delete the temporary folder ({FormatUtils.Bytes(dirSize)}) of this encode?", "Delete temp folder?", MessageBoxButtons.YesNo);
328332

329-
if (dialog == DialogResult.No)
333+
if (dialog == DialogResult.Yes)
330334
IoUtils.TryDeleteIfExists(dir);
331335
}
332336

0 commit comments

Comments
 (0)