Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace prune-files: also removes remote FLocats #1234

Open
bertsky opened this issue Jun 6, 2024 · 0 comments
Open

workspace prune-files: also removes remote FLocats #1234

bertsky opened this issue Jun 6, 2024 · 0 comments
Assignees

Comments

@bertsky
Copy link
Collaborator

bertsky commented Jun 6, 2024

The documentation for the prune-files command says:

Removes mets:files that point to non-existing local files

However, that's not what is implemented:

def prune_files(ctx, file_grp, mimetype, page_id, file_id):
"""
Removes mets:files that point to non-existing local files
(If any ``FILTER`` starts with ``//``, then its remainder
will be interpreted as a regular expression.)
"""
workspace = Workspace(ctx.resolver, directory=ctx.directory, mets_basename=ctx.mets_basename, automatic_backup=ctx.automatic_backup)
with pushd_popd(workspace.directory):
for f in workspace.find_files(
file_id=file_id,
file_grp=file_grp,
mimetype=mimetype,
page_id=page_id,
):
try:
if not f.local_filename or not exists(f.local_filename):
workspace.mets.remove_file(f.ID)

So either the documentation should read…

Removes mets:files that do not point to existing local files

…or the implementation should not remove files that also have a .url.

Since we also have workspace find ... --undo-download (removing .local_filename in METS and filesystem for those entries which also have a .url – if implemented properly, i.e. fixing #1150) the former makes more sense to me, as the latter would be redundant behaviour.

@kba kba self-assigned this Jul 3, 2024
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

No branches or pull requests

2 participants