Worker that cleans up orphaned artifact files
Summary
Currently, there's no scheduled cleanup of orphaned artifacts. This results in leaking storage space. We should attempt to solve this.
Proposal
There's a handy way we can find orphaned artifact files - since we dynamically generate their names using the project and job IDs, we can search the artifact directory for paths that don't match existing projects or jobs.
def hashed_path
File.join(disk_hash[0..1], disk_hash[2..3], disk_hash,
model.created_at.utc.strftime('%Y_%m_%d'), model.job_id.to_s, model.id.to_s)
end
def legacy_path
File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.job_id.to_s)
end
e.g. we can try and search for paths that contain job and project IDs that are no longer in the database.