Skip to content

ignore errors cleaning up temporary files #36594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
The Windows Agent MSI no longer fails if it is unable to delete temporary
files related to extracting the embedded Python distribution.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,24 @@ private static ActionResult DecompressPythonDistribution(
session.Log($"{embedded} not found, skipping decompression.");
}

File.Delete(Path.Combine(projectLocation, "bin", "7zr.exe"));
File.Delete(embedded);
// delete the files we don't need anymore
var cleanupFiles = new[] {
Path.Combine(projectLocation, "bin", "7zr.exe"),
embedded
};
foreach (var file in cleanupFiles)
{
try
{
File.Delete(file);
}
catch (Exception e)
{
session.Log($"Error while deleting {file}: {e}");
// don't fail if we can't delete the file, it's not critical
// and we've seen cases where antivirus may have been holding the file open
}
}
}
catch (Exception e)
{
Expand Down
Loading