omero admin cleanse: handle missing directories in the ManagedRepository#492
Merged
sbesson merged 1 commit intoome:masterfrom Mar 25, 2026
Merged
Conversation
This commit tries to improve the handling a ManagedRepository directory registered in the database but missing from disk. Currently, `omero admin cleanse` fails with a `SecurityViolation` server error as per the contract of `repo.listFiles()`. This change catches the server error, logs the message in the command output with an `ERROR` prefix and returns `False` to indicate no empty directory was found. This mechanism should allow the command to continue scanning the ManagedRepository, report other errors or empty directories and provide a more complete audit allowing the administrator to review and take the appropriate action.
kkoz
approved these changes
Feb 17, 2026
Contributor
kkoz
left a comment
There was a problem hiding this comment.
Works as expected. Without the patch, I get
omero.ValidationException: exception ::omero::ValidationException
{
serverStackTrace =
serverExceptionClass =
message = /kevin_2/2026-02/17/ does not exist
}
But with it I get
/OMERO/ManagedRepository
ERROR: /kevin_2/2026-02/17/09-41-29.533/ does not exist
mabruce
approved these changes
Mar 24, 2026
mabruce
left a comment
There was a problem hiding this comment.
Worked for me. The directory check reported an ERROR for the missing directory and then proceeded to check the rest of the ManagedRepository.
omero admin cleanse --dry-run --subdirectory ManagedRepository --verbose /OMERO
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.
This commit tries to improve the handling a ManagedRepository directory registered in the database but missing from disk. Currently,
omero admin cleansefails with aSecurityViolationserver error as per the contract ofrepo.listFiles().This change catches the server error, logs the message in the command output with an
ERRORprefix and returnsFalseto indicate no empty directory was found. This mechanism should allow the command to continue scanning the ManagedRepository, report other errors or empty directories and provide a more complete audit allowing the administrator to review and take the appropriate action.To reproduce the issue:
omero importto create a new/OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/<hh>-<mm>-<ss>-<SSS>directory under the databaseomero delete, this should delete the original file and the import log but keep empty directories/OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/<hh>-<mm>-<ss>-<SSS>/OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/With OMERO.py 5.22.0,
omero admin cleanse --dry-run /OMEROshould fail with aSecurityViolationmessage similar/<user>_<id>/<YYYY>-<MM>/<DD>/ does not existand abort.With this PR included, the same command should log the error message indicating the folder does not exist but continue processing the binary repository.