[ome-users] Deleting an object together with its directory in ManagedRepository
Andrii Iudin
andrii at ebi.ac.uk
Mon Nov 20 10:42:35 GMT 2017
Hi Mark,
Many thanks for pointing the places in the code that are relevant to the
deletion and for providing an alternative suggestion!
Best regards,
Andrii
On 17/11/2017 09:10, Mark Carroll wrote:
> On 11/16/2017 12:28 PM, Andrii Iudin wrote:
>
>> Thank you for explaining the current situation. I will check with my
>> supervisor if we can allocate resources to implementing this, however,
>> please point to the relevant code.
>
> When a file is deleted by normal means then the row from the
> originalfile table in the database is removed by the execute() in,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/blitz/src/omero/cmd/graphs/Delete2I.java#L170
>
>
> This execute method applies the deleteInstances in,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/blitz/src/omero/cmd/graphs/BaseGraphTraversalProcessor.java#L54
>
>
> Later the underlying files are deleted by buildResponse in,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/blitz/src/omero/cmd/graphs/Delete2I.java#L199
>
>
> These are deleted from the bottom of the tree up. There is a check at,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/dsl/resources/ome/dsl/psql-footer.vm#L849
>
>
> that a directory may not be deleted unless it is empty so back at,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/blitz/src/omero/cmd/graphs/Delete2I.java#L155
>
>
> we rearranged the list of things to delete so that the "leaves" get
> deleted first. It is the value returned from here that was fed to
> buildResponse above.
>
> Separately you may find it helpful to see how we implement
> http://downloads.openmicroscopy.org/omero/5.4.0/api/slice2html/omero/grid/Repository.html#deletePaths
>
> (when recursive==true) in,
>
> https://github.com/openmicroscopy/openmicroscopy/blob/v5.4.0/components/blitz/src/ome/services/blitz/repo/PublicRepositoryI.java#L291
>
>
> Depending on your needs, you may find it easiest to simply make
> client-side adjustments -- whether to OMERO.cli or OMERO.web or your own
> scripts or whatever -- that follows something like this path:
>
> 1. Do the Delete2 cmd with "dryRun" set to find which OriginalFile
> instances are to be deleted.
> 2. Query the database for the path of those instances.
> 3. Do the delete from (1) for real, without dryRun.
> 4. Query the database for any OriginalFiles that have the same path as
> anything from (2).
> 5. For anything from (2) for which (4) returns no results (i.e. that
> directory is now empty), shunt the last component of that path over to
> the "name" property so you can query for the OriginalFile for that
> parent directory.
> 6. For each of (5)'s parent directories where canDelete() == true add it
> to a new to-delete list.
> 7. Start from (1) with your new to-delete list.
>
> It's neither fast nor pretty, but it's at least easier than hacking the
> server's Delete2I directly.
>
> -- Mark
>
> The University of Dundee is a registered Scottish Charity, No: SC015096
> _______________________________________________
> ome-users mailing list
> ome-users at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
More information about the ome-users
mailing list