Improve action debug output

This commit is contained in:
Jaex 2021-03-26 22:42:54 +03:00
parent a8f106348e
commit 3c7d6b264a
2 changed files with 17 additions and 1 deletions

View file

@ -104,14 +104,18 @@ public string Run(string inputPath)
CreateNoWindow = HiddenWindow
};
DebugHelper.WriteLine($"Action input: \"{inputPath}\" ({Helpers.GetFileSizeReadable(inputPath)})");
DebugHelper.WriteLine($"Action run: \"{psi.FileName}\" {psi.Arguments}");
process.StartInfo = psi;
DebugHelper.WriteLine($"CLI: \"{psi.FileName}\" {psi.Arguments}");
process.Start();
process.WaitForExit();
}
if (!string.IsNullOrEmpty(outputPath) && File.Exists(outputPath))
{
DebugHelper.WriteLine($"Action output: \"{outputPath}\" ({Helpers.GetFileSizeReadable(outputPath)})");
if (DeleteInputFile && !inputPath.Equals(outputPath, StringComparison.OrdinalIgnoreCase) && File.Exists(inputPath))
{
DebugHelper.WriteLine("Deleting input file: " + inputPath);

View file

@ -940,6 +940,18 @@ public static long GetFileSize(string filePath)
return -1;
}
public static string GetFileSizeReadable(string filePath, bool binaryUnits = false)
{
long fileSize = GetFileSize(filePath);
if (fileSize >= 0)
{
return fileSize.ToSizeString(binaryUnits);
}
return "";
}
public static void CreateDirectory(string directoryPath)
{
if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))