remove_source_content
What it does
remove_source_content strips down an article's most recent module folder to only the handful of files worth keeping long-term, deleting everything else (full-text PDFs, XML, images, and other bulky harvested content that's already been consumed by later pipeline stages and doesn't need to keep taking up space on the NAS afterward).
Information for developers
This is an example in the repo of a retain-list-based cleanup pattern, ie, instead of deleting specific known files, it keeps a short allowlist and removes everything else. If there is a need to shrink a folder down to just its essential records utility, this template would be useful.
Working
It follows the standard previous_module convention (temp folder, copy content, rename on success) like a normal pipeline module, but the actual "processing" step is a single call:
retain = [constants.MODULE_DIP_EXPORT, constants.DOCUMENTATION_DIR, constants.ARCHIVEMATICA_TRANSFER_STATUS_FILE,
constants.TOOLBOX_TEXT_ID_FILE, constants.RELAXNG_VALIDATION_SUCCESS_INDICATOR,
constants.ARTICLE_METADATA_FILE_NAME]
...
cleanups.purge_directory(temp_current_module_dir, retain=retain)
cleanups.purge_directory (in common/cleanups.py) deletes everything inside the temp module directory except the named entries in retain (eg, the DIP export folder, the processing/ documentation folder (i.e. history.csv), the Archivematica transfer status file, the toolbox text ID file, the RelaxNG validation indicator, and the CrossRef metadata file itself). Everything else (eg, pdf/, xml/, images/, etc), gets deleted.