inveniosoftware / invenio-files-rest

REST API for uploading/downloading files for Invenio.
https://invenio-files-rest.readthedocs.io
MIT License
9 stars 67 forks source link

Add task for cleaning up orphan files #280

Closed max-moser closed 1 year ago

max-moser commented 2 years ago

This PR adds a background task that deletes orphaned files from DB and disk (i.e. FileInstances that don't have any ObjectVersions linked with them anymore). It is a slightly adapted version of our custom CLI command: https://gitlab.tuwien.ac.at/fairdata/invenio-utilities-tuw/-/blob/master/invenio_utilities_tuw/cli/files.py#L240

Note: The CLI command has been working well enough to clean up unreferenced files of deleted drafts, but I found that the force flag has to be provided because the storage is marked as not writable.

I'll still add tests for the new task, and then mark this as ready for review.

max-moser commented 1 year ago

updated the PR, tested it out in a local my-site and everything works the changes necessary to make the tests run are contained in https://github.com/inveniosoftware/invenio-files-rest/pull/282

max-moser commented 1 year ago

It seems that a deprecation was turned into a removal in sphinx 6. The deprecation warning from sphinx 5:

/home/mmoser/.local/share/virtualenvs/invenio-files-rest-bsTvguby/lib/python3.10/site-packages/sphinx/domains/python.py:512: RemovedInSphinx60Warning: Python directive method get_signature_prefix() returning a string is deprecated. It must now return a list of nodes. Return value was '(task)'.