Remove the extraction folder also after a failed extraction (#424)

* Remove the extraction folder also after a failed extraction

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the original cleanup comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gmipf
2026-10-17 01:44:24 +02:00
committed by GitHub
parent 055c79343b
commit 0c23b23160

View File

@@ -405,11 +405,13 @@ namespace BinaryObjectScanner
// If we're scanning archives
if (_scanArchives && wrapper is IExtractable extractable)
{
// Get the output path
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
// If the extractable file itself fails
try
{
// Extract and get the output path
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
// Extract to the output path
Directory.CreateDirectory(tempPath);
_ = extractable.Extract(tempPath, _includeDebug);
@@ -426,7 +428,13 @@ namespace BinaryObjectScanner
// Append the values
protections.Append(subProtections);
}
}
catch (Exception ex)
{
if (_includeDebug) Console.Error.WriteLine(ex);
}
finally
{
// If temp directory cleanup fails
try
{
@@ -438,10 +446,6 @@ namespace BinaryObjectScanner
if (_includeDebug) Console.Error.WriteLine(ex);
}
}
catch (Exception ex)
{
if (_includeDebug) Console.Error.WriteLine(ex);
}
}
#endregion