Zum Inhalt

remove_dip

What it does

remove_dip deletes an article's DIP (Dissemination Information Package) folder after it's no longer needed on the NAS (specifically, the DIP that archivematica_dip_export produced earlier in the pipeline). A DIP is typically only needed transiently (e.g. to be picked up by dspace_article_ingest or another downstream consumer); once that's happened, keeping a full copy around on the NAS is not required.

Module structure

This is an example of a module that follows the standard previous_module convention (temp folder, rename on success, mark-processed) but does almost nothing with the article's content — its entire job is to verify a directory looks the way it's expected to, then delete it. If writing a cleanup/maintenance module, this is a simpler template to copy from, rather than a full harvesting module.

Module working

For each eligible article, it looks at the DIP folder inside the current temp module directory (path resolved via archivematica_dip_export.tasks.get_dip_dir_path) and applies a safety check before deleting anything:

  • The DIP folder must exist, and it must contain exactly one subdirectory (the actual exported package). If it contains zero or more than one subdirectory, or doesn't exist at all, the module refuses to delete it and instead marks the article as stop-processing (this is a safeguard against deleting something that doesn't look like a normal, single, completed DIP export).
  • If the check passes, the whole DIP directory is removed via shutil.rmtree, and a minimal history.csv entry is written recording the removal.
  • If shutil.rmtree itself fails (e.g. a permissions issue, OSError), the article is also marked stop-processing.