Skip to content

First pass at better cleanse dry-run output#491

Merged
sbesson merged 6 commits intoome:masterfrom
kkoz:cleanse-dry-run-patch
Feb 9, 2026
Merged

First pass at better cleanse dry-run output#491
sbesson merged 6 commits intoome:masterfrom
kkoz:cleanse-dry-run-patch

Conversation

@kkoz
Copy link
Copy Markdown
Contributor

@kkoz kkoz commented Jan 22, 2026

Replace #488

Currently, cleanse only operates on files, not directories. It will also only remove files which have integer file names, all others are ignored.

We have cases where there are "files" in the binary repository which take the form of a directory, with the underlying data fragmented into multiple files inside that directory. The directory has the OriginalFile ID as its name. Currently, there is no way through OMERO tooling to identify or delete these files from the binary repository.

This PR modifies the logic of omero admin cleanse --dry-run to support two flags: --subdirectory and --verbose.
When --subdirectory is provided, only the given subdirectory Files, Pixels, or Thumbnails, will be searched.
When --verbose is used with --dry-run, the old output will be displayed. Otherwise, a much smaller output only listing files and directories which are candidates for removal will be displayed.

To test, do the following:

Create and save two OriginalFile objects in the database and record the IDs.
Create a directory with one of the IDs as the name in the proper location in the binary repository. Optionally you can add files to the directory. Do the same with a file and the other ID.
Run omero admin cleanse --dry-run --subdirectory Files You should NOT see the directory or the file.
Run omero admin cleanse --dry-run --subdirectory Files --verbose You should see the directory and file marked (keep)
Delete the OriginalFile objects in the DB (you may need to recreate the file)
Run omero admin cleanse --dry-run --subdirectory Files with or without --verbose. You should see the folder marked (removedir) and the file marked (remove)
Run omero admin cleanse with or without --subdirectory and without --dry-run. You should see a message No action taken for directory <Your Path> and the directory (and all its contents) should still be there. The individual file should have been removed.

Note that technically you don't even need to use your actual OMERO data dir to do this testing. You can create a temporary directory with a Files subdirectory and use that as the argument instead.

Also note that instead of omero admin cleanse, you can run python cleanse.py directly.

@kkoz kkoz requested a review from sbesson January 22, 2026 20:28
@sbesson sbesson added this to the 5.22.0 milestone Jan 23, 2026
Copy link
Copy Markdown
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

At first glance, this looks like a great usability improvement

omero@mauve:~$ omero admin cleanse /OMERO --dry-run --subdirectory Files --subdirectory Thumbnails
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Thumbnails
Cleansing context: 0 files (0 bytes)
omero@mauve:~$ omero admin cleanse /OMERO --dry-run --subdirectory Files --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
   \_ /OMERO/Files/Dir-089/89681 (remove)
   \_ /OMERO/Files/Dir-089/89646 (remove)
   \_ /OMERO/Files/Dir-089/89550 (remove)
   \_ /OMERO/Files/Dir-089/89597 (remove)
   \_ /OMERO/Files/Dir-089/89608 (remove)
   \_ /OMERO/Files/Dir-089/89537 (remove)
   \_ /OMERO/Files/Dir-089/89549 (remove)
   \_ /OMERO/Files/Dir-089/89605 (remove)
   \_ /OMERO/Files/Dir-089/89643 (remove)
   \_ /OMERO/Files/Dir-089/89606 (remove)
   \_ /OMERO/Files/Dir-089/89519 (remove)
   \_ /OMERO/Files/Dir-089/89658 (remove)
   \_ /OMERO/Files/Dir-089/89666 (remove)
   \_ /OMERO/Files/Dir-089/89512 (remove)
   \_ /OMERO/Files/Dir-089/89689 (remove)
   \_ /OMERO/Files/Dir-089/89588 (remove)
   \_ /OMERO/Files/Dir-089/89661 (remove)
   \_ /OMERO/Files/Dir-089/89522 (remove)
   \_ /OMERO/Files/Dir-089/89675 (remove)
   \_ /OMERO/Files/Dir-089/89679 (remove)
   \_ /OMERO/Files/Dir-089/89626 (remove)
   \_ /OMERO/Files/Dir-089/89636 (remove)
   \_ /OMERO/Files/Dir-089/89621 (remove)
   \_ /OMERO/Files/Dir-089/89672 (remove)
   \_ /OMERO/Files/Dir-089/89533 (remove)
   \_ /OMERO/Files/Dir-089/89652 (remove)
   \_ /OMERO/Files/Dir-089/89660 (remove)
   \_ /OMERO/Files/Dir-089/89650 (remove)
   \_ /OMERO/Files/Dir-089/89516 (remove)
   \_ /OMERO/Files/Dir-089/89640 (remove)
   \_ /OMERO/Files/Dir-089/89613 (remove)
   \_ /OMERO/Files/Dir-089/89518 (remove)
   \_ /OMERO/Files/Dir-089/89523 (remove)
   \_ /OMERO/Files/Dir-089/89629 (remove)
   \_ /OMERO/Files/Dir-089/89565 (remove)
   \_ /OMERO/Files/Dir-089/89649 (remove)
   \_ /OMERO/Files/Dir-089/89690 (remove)
   \_ /OMERO/Files/Dir-089/89545 (remove)
   \_ /OMERO/Files/Dir-089/89602 (remove)
   \_ /OMERO/Files/Dir-089/89596 (remove)
   \_ /OMERO/Files/Dir-089/89674 (remove)
   \_ /OMERO/Files/Dir-089/89569 (remove)
   \_ /OMERO/Files/Dir-089/89559 (remove)
   \_ /OMERO/Files/Dir-089/89547 (remove)
   \_ /OMERO/Files/Dir-089/89634 (remove)
   \_ /OMERO/Files/Dir-089/89552 (remove)
   \_ /OMERO/Files/Dir-089/89647 (remove)
   \_ /OMERO/Files/Dir-089/89584 (remove)
   \_ /OMERO/Files/Dir-089/89589 (remove)
   \_ /OMERO/Files/Dir-089/89514 (remove)
   \_ /OMERO/Files/Dir-089/89616 (remove)
   \_ /OMERO/Files/Dir-089/89576 (remove)
   \_ /OMERO/Files/Dir-089/89678 (remove)
   \_ /OMERO/Files/Dir-089/89526 (remove)
   \_ /OMERO/Files/Dir-089/89644 (remove)
   \_ /OMERO/Files/Dir-089/89638 (remove)
   \_ /OMERO/Files/Dir-089/89577 (remove)
   \_ /OMERO/Files/Dir-089/89657 (remove)
   \_ /OMERO/Files/Dir-089/89587 (remove)
   \_ /OMERO/Files/Dir-089/89682 (remove)
   \_ /OMERO/Files/Dir-089/89535 (remove)
   \_ /OMERO/Files/Dir-089/89667 (remove)
   \_ /OMERO/Files/Dir-089/89617 (remove)
   \_ /OMERO/Files/Dir-089/89610 (remove)
   \_ /OMERO/Files/Dir-089/89623 (remove)
   \_ /OMERO/Files/Dir-089/89557 (remove)
   \_ /OMERO/Files/Dir-089/89659 (remove)
   \_ /OMERO/Files/Dir-089/89582 (remove)
   \_ /OMERO/Files/Dir-089/89534 (remove)
   \_ /OMERO/Files/Dir-089/89513 (remove)
   \_ /OMERO/Files/Dir-089/89668 (remove)
   \_ /OMERO/Files/Dir-089/89515 (remove)
   \_ /OMERO/Files/Dir-089/89633 (remove)
   \_ /OMERO/Files/Dir-089/89614 (remove)
   \_ /OMERO/Files/Dir-089/89521 (remove)
   \_ /OMERO/Files/Dir-089/89570 (remove)
   \_ /OMERO/Files/Dir-089/89568 (remove)
   \_ /OMERO/Files/Dir-089/89536 (remove)
   \_ /OMERO/Files/Dir-089/89641 (remove)
   \_ /OMERO/Files/Dir-089/89603 (remove)
   \_ /OMERO/Files/Dir-089/89585 (remove)
   \_ /OMERO/Files/Dir-089/89527 (remove)
   \_ /OMERO/Files/Dir-089/89581 (remove)
   \_ /OMERO/Files/Dir-089/89684 (remove)
   \_ /OMERO/Files/Dir-089/89686 (remove)
   \_ /OMERO/Files/Dir-089/89553 (remove)
   \_ /OMERO/Files/Dir-089/89561 (remove)
   \_ /OMERO/Files/Dir-089/89683 (remove)
   \_ /OMERO/Files/Dir-089/89593 (remove)
   \_ /OMERO/Files/Dir-089/89548 (remove)
   \_ /OMERO/Files/Dir-089/89529 (remove)
   \_ /OMERO/Files/Dir-089/89517 (remove)
   \_ /OMERO/Files/Dir-089/89579 (remove)
   \_ /OMERO/Files/Dir-089/89560 (remove)
   \_ /OMERO/Files/Dir-089/89530 (remove)
   \_ /OMERO/Files/Dir-089/89551 (remove)
   \_ /OMERO/Files/Dir-089/89531 (remove)
   \_ /OMERO/Files/Dir-089/89651 (remove)
   \_ /OMERO/Files/Dir-089/89648 (remove)
   \_ /OMERO/Files/Dir-089/89592 (remove)
   \_ /OMERO/Files/Dir-089/89607 (remove)
   \_ /OMERO/Files/Dir-089/89618 (remove)
   \_ /OMERO/Files/Dir-089/89567 (remove)
   \_ /OMERO/Files/Dir-089/89653 (remove)
   \_ /OMERO/Files/Dir-089/89620 (remove)
   \_ /OMERO/Files/Dir-089/89635 (remove)
   \_ /OMERO/Files/Dir-089/89598 (remove)
   \_ /OMERO/Files/Dir-089/89558 (remove)
   \_ /OMERO/Files/Dir-089/89604 (remove)
   \_ /OMERO/Files/Dir-089/89520 (remove)
   \_ /OMERO/Files/Dir-089/89542 (remove)
   \_ /OMERO/Files/Dir-089/89619 (remove)
   \_ /OMERO/Files/Dir-089/89524 (remove)
   \_ /OMERO/Files/Dir-089/89645 (remove)
   \_ /OMERO/Files/Dir-089/89612 (remove)
   \_ /OMERO/Files/Dir-089/89631 (remove)
   \_ /OMERO/Files/Dir-089/89685 (remove)
   \_ /OMERO/Files/Dir-089/89615 (remove)
   \_ /OMERO/Files/Dir-089/89609 (remove)
   \_ /OMERO/Files/Dir-089/89669 (remove)
   \_ /OMERO/Files/Dir-089/89540 (remove)
   \_ /OMERO/Files/Dir-089/89544 (remove)
   \_ /OMERO/Files/Dir-089/89662 (remove)
   \_ /OMERO/Files/Dir-089/89664 (remove)
   \_ /OMERO/Files/Dir-089/89637 (remove)
   \_ /OMERO/Files/Dir-089/89655 (remove)
   \_ /OMERO/Files/Dir-089/89600 (remove)
   \_ /OMERO/Files/Dir-089/89625 (remove)
   \_ /OMERO/Files/Dir-089/89562 (remove)
   \_ /OMERO/Files/Dir-089/89528 (remove)
   \_ /OMERO/Files/Dir-089/89554 (remove)
   \_ /OMERO/Files/Dir-089/89586 (remove)
   \_ /OMERO/Files/Dir-089/89611 (remove)
   \_ /OMERO/Files/Dir-089/89571 (remove)
   \_ /OMERO/Files/Dir-089/89639 (remove)
   \_ /OMERO/Files/Dir-089/89632 (remove)
   \_ /OMERO/Files/Dir-089/89670 (remove)
   \_ /OMERO/Files/Dir-089/89627 (remove)
   \_ /OMERO/Files/Dir-089/89680 (remove)
   \_ /OMERO/Files/Dir-089/89556 (remove)
   \_ /OMERO/Files/Dir-089/89590 (remove)
   \_ /OMERO/Files/Dir-089/89566 (remove)
   \_ /OMERO/Files/Dir-089/89676 (remove)
   \_ /OMERO/Files/Dir-089/89555 (remove)
   \_ /OMERO/Files/Dir-089/89601 (remove)
   \_ /OMERO/Files/Dir-089/89580 (remove)
   \_ /OMERO/Files/Dir-089/89677 (remove)
   \_ /OMERO/Files/Dir-089/89578 (remove)
   \_ /OMERO/Files/Dir-089/89630 (remove)
   \_ /OMERO/Files/Dir-089/89541 (remove)
   \_ /OMERO/Files/Dir-089/89575 (remove)
   \_ /OMERO/Files/Dir-089/89564 (remove)
   \_ /OMERO/Files/Dir-089/89642 (remove)
   \_ /OMERO/Files/Dir-089/89624 (remove)
   \_ /OMERO/Files/Dir-089/89622 (remove)
   \_ /OMERO/Files/Dir-089/89691 (remove)
   \_ /OMERO/Files/Dir-089/89599 (remove)
   \_ /OMERO/Files/Dir-089/89654 (remove)
   \_ /OMERO/Files/Dir-089/89573 (remove)
   \_ /OMERO/Files/Dir-089/89563 (remove)
   \_ /OMERO/Files/Dir-089/89574 (remove)
   \_ /OMERO/Files/Dir-089/89665 (remove)
   \_ /OMERO/Files/Dir-089/89546 (remove)
   \_ /OMERO/Files/Dir-089/89628 (remove)
   \_ /OMERO/Files/Dir-089/89538 (remove)
   \_ /OMERO/Files/Dir-089/89543 (remove)
   \_ /OMERO/Files/Dir-089/89572 (remove)
   \_ /OMERO/Files/Dir-089/89539 (remove)
   \_ /OMERO/Files/Dir-089/89671 (remove)
   \_ /OMERO/Files/Dir-089/89591 (remove)
   \_ /OMERO/Files/Dir-089/89673 (remove)
   \_ /OMERO/Files/Dir-089/89595 (remove)
   \_ /OMERO/Files/Dir-089/89583 (remove)
   \_ /OMERO/Files/Dir-089/89594 (remove)
   \_ /OMERO/Files/Dir-089/89656 (remove)
   \_ /OMERO/Files/Dir-089/89663 (remove)
   \_ /OMERO/Files/Dir-089/89687 (remove)
   \_ /OMERO/Files/Dir-089/89688 (remove)
   \_ /OMERO/Files/Dir-089/89532 (remove)
   \_ /OMERO/Files/Dir-089/89525 (remove)
Cleansing context: 180 files (549 bytes)

I'll do some extra testing/validation tomorrow including running outside of dry-run mode.

Copy link
Copy Markdown
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

Functionally tested the cleansing of Files which is the original goal of this PR. On a development instance, confirmed that cleanse can now run on Files alone

omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files 
...

   \_ /OMERO/Files/Dir-089/89687 (remove)
   \_ /OMERO/Files/Dir-089/89688 (remove)
   \_ /OMERO/Files/Dir-089/89532 (remove)
   \_ /OMERO/Files/Dir-089/89525 (remove)
Cleansing context: 180 files (549 bytes)
omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files 
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero@mauve:~$ omero admin cleanse /OMERO --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)

Tested the Pixels and Thumbnails directory cleansing

omero@mauve:~$ omero admin cleanse /OMERO --dry-run --subdirectory Pixels
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
/OMERO/Pixels does not exist. Skipping...
None
omero@mauve:~$ omero admin cleanse /OMERO --dry-run --subdirectory Thumbnails
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Thumbnails
Cleansing context: 0 files (0 bytes)

For a single file original file, confirmed the file is deleted from the server-side delete command and cleanse is a no-op

omero@mauve:~$ omero obj new OriginalFile path=test name=test
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7556
omero@mauve:~$ touch /OMERO/Files/Dir-007/7556
omero@mauve:~$ file /OMERO/Files/Dir-007/7556
/OMERO/Files/Dir-007/7556: empty
omero@mauve:~$ omero delete OriginalFile:7556
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7556 ok
omero@mauve:~$ file /OMERO/Files/Dir-007/7556
/OMERO/Files/Dir-007/7556: cannot open `/OMERO/Files/Dir-007/7556' (No such file or directory)
omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system

When creating an OriginalFile and artificially inserting a directory with a single file, I confirm the delete command does not remove the directory as expected. However, neither the cleanse command from this PR does not clean its content either. The underlying file is marked as ignored/keep when passing the verbose flag.

omero@mauve:~$ omero obj new OriginalFile path=test name=test
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7557
omero@mauve:~$ mkdir /OMERO/Files/Dir-007/7557
omero@mauve:~$ touch /OMERO/Files/Dir-007/7557/foo
omero@mauve:~$ ls /OMERO/Files/Dir-007/7557/
foo
omero@mauve:~$ omero delete OriginalFile:7557
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7557 ok
omero@mauve:~$ ls /OMERO/Files/Dir-007/7557/
foo
omero@mauve:~$  omero admin cleanse /OMERO --subdirectory Files --dry-run
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)
omero@mauve:~$  omero admin cleanse /OMERO --subdirectory Files --dry-run --verbose | grep 7557/
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
   \_ /OMERO/Files/Dir-007/7557/foo (ignored/keep)
omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero@mauve:~$ ls /OMERO/Files/Dir-007/7557/ 
foo

In addition to the testing above:

  • https://github.com/ome/omero-py/pull/491/changes#r2728256792 raises the question of whether ManagedRepository should be supported to restrict the cleanse command
  • on the usage of cleanse.py directly, I would almost be inclined to deprecated omero.util.cleanse.main and have omero admin cleanse as the only supported command-line entry point moving forward

self.bytes_cleansed = size
if self.dry_run:
print(r" \_ %s (remove)" % path)
dry_run_msg = f" \_ {path} (remove)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not used anywhere?

@kkoz
Copy link
Copy Markdown
Contributor Author

kkoz commented Jan 27, 2026

@sbesson Happy to deprecate main in cleanse.py if that's what we want. I think it's very unlikely to have negative user impact since I doubt almost anyone is using it.

Copy link
Copy Markdown
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

Let's mark omero.util.cleanse.main as deprecated so that we can remove it in a future backwards-incompatible release.

Retested the files cleansing scenario as follows:

  1. creating 2 OriginalFiles, one as a file and one as a folder, and testing omero admin cleanse --dry-run
omero@mauve:~$ omero obj new OriginalFile name=folder path=/dev/null
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7811
omero@mauve:~$ omero obj new OriginalFile name=file path=/dev/null
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7812
omero@mauve:~$ mkdir /OMERO/Files/Dir-007/7811
omero@mauve:~$ touch /OMERO/Files/Dir-007/7811/test
omero@mauve:~$ touch /OMERO/Files/Dir-007/7812
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO -v | grep /781
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
   \_ /OMERO/Files/Dir-007/7810 (keep)
   \_ /OMERO/Files/Dir-007/7812 (keep)
   \_ /OMERO/Files/Dir-007/7811/test (ignored/keep)
omero@mauve:~$ 
  1. deleting the OriginalFile objects from the DB, recreating the single file and testing the dry-run option
omero@mauve:~$ omero delete OriginalFile:7811
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7811 ok
omero@mauve:~$ omero delete OriginalFile:7812
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7812 ok
omero@mauve:~$ ls /OMERO/Files/Dir-007/7811
test
omero@mauve:~$ ls /OMERO/Files/Dir-007/7812
ls: cannot access '/OMERO/Files/Dir-007/7812': No such file or directory
omero@mauve:~$ touch /OMERO/Files/Dir-007/7812
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
   \_ /OMERO/Files/Dir-007/7812 (remove)
Cleansing context: 1 files (0 bytes)
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO -v | grep /781
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
   \_ /OMERO/Files/Dir-007/7810 (keep)
   \_ /OMERO/Files/Dir-007/7812 (remove)
   \_ /OMERO/Files/Dir-007/7811/test (ignored/keep)
  1. running omero admin cleanse outside dry-run mode
omero@mauve:~$ omero admin cleanse --subdirectory Files /OMERO
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)
  1. creating a directory + file under Files that does not match the ID layout
omero@mauve:~$ mkdir /OMERO/Files/foo
omero@mauve:~$ touch /OMERO/Files/foo/bar
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO -v | grep foo
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
   \_ /OMERO/Files/foo/bar (ignored/keep)
omero@mauve:~$ omero admin cleanse --dry-run --subdirectory Files /OMERO 
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)

For the single-file scenario, everything work as expected and the verbosity/subdirectory logic is really useful to get a concise summary.
For the directory scenario, there are deviations from the expectations set in the description of this PR:

  • the removedir annotation never seems to be printed
  • a file under a subdirectory is always ignored and never cleaned up either under the ID structure like /OMERO/Files/Dir-007/7811/ or outside like /OMERO/Files/foo/bar

@kkoz
Copy link
Copy Markdown
Contributor Author

kkoz commented Feb 2, 2026

a file under a subdirectory is always ignored and never cleaned up either under the ID structure like /OMERO/Files/Dir-007/7811/ or outside like /OMERO/Files/foo/bar

@sbesson could you elaborate on what you expected to see here? Currently neither of these would get cleaned up, and my intention here was to not change the actual cleaning up of files/directories, just to change what gets printed out.

@sbesson
Copy link
Copy Markdown
Member

sbesson commented Feb 2, 2026

@sbesson could you elaborate on what you expected to see here? Currently neither of these would get cleaned up, and my intention here was to not change the actual cleaning up of files/directories, just to change what gets printed out.

I think I was unclear on the expectations, thanks for clarifying. I'll review the latest commit accordingly.

@sbesson sbesson self-requested a review February 2, 2026 19:47
Copy link
Copy Markdown
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

Retesting the original scenario by creating 2 original files and artificially generating a file and a directory

omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)
omero@mauve:~$ omero obj new OriginalFile name=test path=test
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7965
omero@mauve:~$ omero obj new OriginalFile name=test path=test
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
OriginalFile:7966
omero@mauve:~$ touch /OMERO/Files/Dir-007/7965
omero@mauve:~$ mkdir /OMERO/Files/Dir-007/7966
omero@mauve:~$ touch /OMERO/Files/Dir-007/7966/test
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)

Confirmed that the file scenario still works as expected:

  • omero delete deletes the object and the file
  • after artificially recreating the file, omero admin cleanse flags and deletes the file
omero@mauve:~$ omero delete OriginalFile:7965
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7965 ok
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)
omero@mauve:~$ touch /OMERO/Files/Dir-007/7965
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
   \_ /OMERO/Files/Dir-007/7965 (remove)
Cleansing context: 1 files (0 bytes)
omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
Cleansing context: 0 files (0 bytes)

Confirmed that the directory behavior is unchanged

  • omero delete deletes the object but not the directory
  • omero admin cleanse --dry-run marks the directory as removedir
  • omero admin cleanse reports the directory but does not remove it
omero@mauve:~$ omero delete OriginalFile:7966
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
omero.cmd.Delete2 OriginalFile:7966 ok
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
   \_ /OMERO/Files/Dir-007/7966 (removedir)
Cleansing context: 1 files (4096 bytes)
omero@mauve:~$ omero admin cleanse /OMERO --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
No action taken for directory /OMERO/Files/Dir-007/7966
omero@mauve:~$ omero admin cleanse /OMERO  --dry-run --subdirectory Files
Using session for root@localhost:4064. Idle timeout: 10 min. Current group: system
Reconciling OMERO data directory...
 /OMERO/Files
   \_ /OMERO/Files/Dir-007/7966 (removedir)
Cleansing context: 1 files (4096 bytes)

Both the ability to restrict the cleansing to a subdirectory of the OMERO binary data repository and the control of the verbosity of the output in dry-run mode are great improvements to the overall usability of this administrative utility.

@sbesson sbesson merged commit f32e7a0 into ome:master Feb 9, 2026
12 checks passed
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.

2 participants