diff --git a/LTA/LTAIngest/LTAIngestServer/LTAIngestAdminServer/lib/ingestjobmanagementserver.py b/LTA/LTAIngest/LTAIngestServer/LTAIngestAdminServer/lib/ingestjobmanagementserver.py index 0c95cc0f10d913f7efee600b53cb58422c40fe6f..405a26ff7683c1caf2cc15943c3d557926b6aef4 100644 --- a/LTA/LTAIngest/LTAIngestServer/LTAIngestAdminServer/lib/ingestjobmanagementserver.py +++ b/LTA/LTAIngest/LTAIngestServer/LTAIngestAdminServer/lib/ingestjobmanagementserver.py @@ -430,6 +430,15 @@ class IngestJobManager: shutil.move(current_path, new_path) job_admin_dict['path'] = new_path + # nice cleanup of obsolete empty directories + try: + old_dirname = os.path.dirname(current_path) + if old_dirname.startswith(self.__jobs_dir) and len(os.listdir(old_dirname)) == 0: + logger.info('removing empty jobs directory: %s', old_dirname) + os.rmdir(old_dirname) + except OSError as e: + logger.error(e) + if new_status == JobRemoved or new_status == JobFailed: # send notification # this is (also) picked up by the ingestmomadapter