core icon indicating copy to clipboard operation
core copied to clipboard

undo-download: does not remove files, but removes sole refs

Open bertsky opened this issue 2 years ago • 1 comments

https://github.com/OCR-D/core/blob/742906e330d5ef1139fd18c86b73c154c0a67eae/ocrd/ocrd/cli/workspace.py#L472

This implementation is strange:

  1. if it encounters a file ref without any URL FLocat (i.e. if the file was created by OCR-D itself as output of a processor), then it will still just remove the ref (and thus destroy the information).
  2. it never actually removes files from the filesystem (even the ones it unreferenced).

How is this supposed to be used then?

bertsky avatar Dec 12 '23 11:12 bertsky

if it encounters a file ref without any URL FLocat (i.e. if the file was created by OCR-D itself as output of a processor), then it will still just remove the ref (and thus destroy the information).

That's an oversight, the local FLocat should not be removed if it is the only ref.

On the same note, the behavior of (bulk-)add is currently also wonky, creating both URL and FILE mets:FLocats.

it never actually removes files from the filesystem (even the ones it unreferenced).

It just didn't occur to me, I wanted to make the downloads reversible on the METS level but we can add the option to actually remove the files.

kba avatar Dec 13 '23 13:12 kba

It just didn't occur to me, I wanted to make the downloads reversible on the METS level but we can add the option to actually remove the files.

Then for the sake of consistency I recommend doing the opposite: making the filesystem action the default and adding an option -k, --keep-file Do not delete file from file system.

bertsky avatar Jun 06 '24 08:06 bertsky

It just didn't occur to me, I wanted to make the downloads reversible on the METS level but we can add the option to actually remove the files.

Then for the sake of consistency I recommend doing the opposite: making the filesystem action the default and adding an option -k, --keep-file Do not delete file from file system.

Alternatively, we could implement a generic-purpose command clean, complementary to prune-files and undo-download: removing files in the workspace which are not referenced in the METS.

bertsky avatar Jun 06 '24 09:06 bertsky