Skip to content

Commit 7d61ac1

Browse files
fix(python): avoid FileAlreadyExistsException in venv cleanup (#373)
## Summary - Remove redundant `Files.createFile()` before `Files.write()` in `PythonControllerVirtualEnv` - `Files.write()` already creates the file if it doesn't exist - The `createFile()` call caused `FileAlreadyExistsException` when a previous analysis failed mid-way and left the `requirements.txt` behind in `/tmp/trustify_da_env/` ## Test plan - [x] All existing Python provider tests pass (35 tests, 0 failures) - [x] Manual: trigger a Python analysis that fails (e.g. unresolvable dep), then trigger another — should no longer throw `FileAlreadyExistsException` Implements [TC-3894](https://redhat.atlassian.net/browse/TC-3894) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Chao Wang <chaowan@redhat.com>
1 parent 955d434 commit 7d61ac1

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

src/main/java/io/github/guacsec/trustifyda/utils/PythonControllerVirtualEnv.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public void cleanEnvironment(boolean deleteEnvironment) {
9191
Files.deleteIfExists(envRequirements);
9292
String freezeOutput =
9393
Operations.runProcessGetOutput(pythonEnvironmentDir, pipBinaryLocation, "freeze");
94-
Files.createFile(envRequirements);
9594
Files.write(envRequirements, freezeOutput.getBytes());
9695
Operations.runProcessGetOutput(
9796
pythonEnvironmentDir, pipBinaryLocation, "uninstall", "-y", "-r", "requirements.txt");

0 commit comments

Comments
 (0)