Skip to content

omero admin cleanse: handle missing directories in the ManagedRepository#492

Merged
sbesson merged 1 commit intoome:masterfrom
sbesson:cleanse_managedrepository_missingdirs
Mar 25, 2026
Merged

omero admin cleanse: handle missing directories in the ManagedRepository#492
sbesson merged 1 commit intoome:masterfrom
sbesson:cleanse_managedrepository_missingdirs

Conversation

@sbesson
Copy link
Copy Markdown
Member

@sbesson sbesson commented Feb 16, 2026

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.

To reproduce the issue:

  • import a file via omero import to create a new /OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/<hh>-<mm>-<ss>-<SSS> directory under the database
  • delete the imported image using omero delete, this should delete the original file and the import log but keep empty directories
  • delete /OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/<hh>-<mm>-<ss>-<SSS>
  • delete /OMERO/ManagedRepository/<user>_<id>/<YYYY>-<MM>/<DD>/

With OMERO.py 5.22.0, omero admin cleanse --dry-run /OMERO should fail with a SecurityViolation message similar /<user>_<id>/<YYYY>-<MM>/<DD>/ does not exist and 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.

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.
@sbesson sbesson requested review from kkoz and mabruce February 16, 2026 11:58
Copy link
Copy Markdown
Contributor

@kkoz kkoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

@mabruce mabruce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@sbesson sbesson merged commit 1c5e85b into ome:master Mar 25, 2026
12 checks passed
@sbesson sbesson deleted the cleanse_managedrepository_missingdirs branch March 25, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants