Skip to content

Fix cleanUp to only delete files belonging to the current case#379

Merged
lmdiazangulo merged 1 commit into
devfrom
377-pywrapper-cleanup-fix
May 11, 2026
Merged

Fix cleanUp to only delete files belonging to the current case#379
lmdiazangulo merged 1 commit into
devfrom
377-pywrapper-cleanup-fix

Conversation

@lmdiazangulo
Copy link
Copy Markdown
Contributor

Fixes #377.

Problem

When two different cases described by .fdtd.json files reside in the same folder, calling FDTD.cleanUp() deleted output files for all cases in that folder, not just the one associated with the current instance.

Additionally, the subfolder deletion used a bare name instead of the full path, which would silently fail unless the process CWD happened to be the case folder.

Fix

  • Filter deleted files by requiring os.path.basename(file).startswith(case_name).
  • Filter deleted subfolders by requiring f.startswith(case_name).
  • Use os.path.join(folder, f) for the full subfolder path when calling shutil.rmtree.

Tests

Added test_fdtd_clean_up_does_not_delete_other_cases_files to test/pyWrapper/test_pyWrapper.py that creates fake output files for two different cases in the same folder, calls cleanUp() on one, and asserts the other case's files are untouched.

Resolves #377. The cleanUp method was deleting all output files in
the folder regardless of which FDTD case they belong to. Now it
filters both files and subfolders by the current case name prefix,
so multiple cases in the same folder do not interfere with each other.

Also fix subfolder deletion to use the full path.
@lmdiazangulo lmdiazangulo requested a review from Alberto-o April 23, 2026 07:08
@lmdiazangulo lmdiazangulo added AI assisted Mostly created with AI. Needs special review. pyWrapper labels Apr 23, 2026
@lmdiazangulo lmdiazangulo merged commit 54f8b77 into dev May 11, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted Mostly created with AI. Needs special review. pyWrapper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants