Fix cleanUp to only delete files belonging to the current case#379
Merged
Conversation
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.
Alberto-o
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #377.
Problem
When two different cases described by
.fdtd.jsonfiles reside in the same folder, callingFDTD.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
os.path.basename(file).startswith(case_name).f.startswith(case_name).os.path.join(folder, f)for the full subfolder path when callingshutil.rmtree.Tests
Added
test_fdtd_clean_up_does_not_delete_other_cases_filestotest/pyWrapper/test_pyWrapper.pythat creates fake output files for two different cases in the same folder, callscleanUp()on one, and asserts the other case's files are untouched.