def delete_old_job_files():
    """Deletes job files on disk if modification time exceeds expire time(s)"""
    total_deleted = 0

    # this coded but not enabled since there isn't any authentication and I don't think
    #  anyone should be able to delete jobs older than any arbitrary number of minutes
    if request:
        mmin = request.args.get("mmin")
        teapot_mmin = request.args.get("teapot_mmin")
        if mmin is not None:
            logger.warning(
                "Passing a mmin value to delete_old_job_files() is currently not enabled.  Using %d seconds for regular jobs."
                % REDIS_EXPIRE
            )
        if teapot_mmin is not None:
            logger.warning(
                "Passing a teapot_mmin value to delete_old_job_files() is currently not enabled.  Using %d seconds for teapot jobs."
                % TEAPOT_REDIS_EXPIRE
            )

    # these values represent number of minutes
    teapot_mmin = TEAPOT_REDIS_EXPIRE

    if os.path.exists(JOB_STORAGE_PATH):
        now = time.time()
        # assumption is REDIS_EXPIRE >= TEAPOT_REDIS_EXPIRE
        for file in glob.glob(os.path.join(JOB_STORAGE_PATH, "*.zip")):
            if os.path.isfile(file):
                mtime = os.path.getmtime(file)
                if (now - mtime) > REDIS_EXPIRE:
                    logger.debug(
                        "Deleting job file '%s'. mtime %s; now %s; diff %d seconds; expire threshold %d seconds"
                        % (
                            os.path.basename(file),
                            now,
                            mtime,
                            (now - mtime),
                            REDIS_EXPIRE,
                        )
                    )
                    os.unlink(file)
                    total_deleted += 1
        for file in glob.glob(os.path.join(JOB_STORAGE_PATH, "teapot_*.zip")):
            if os.path.isfile(file):
                mtime = os.path.getmtime(file)
                if (now - mtime) > TEAPOT_REDIS_EXPIRE:
                    logger.debug(
                        "Deleting teapot job file '%s'. mtime %s; now %s; diff %d seconds; expire threshold %d seconds"
                        % (
                            os.path.basename(file),
                            now,
                            mtime,
                            (now - mtime),
                            TEAPOT_REDIS_EXPIRE,
                        )
                    )
                    os.unlink(file)
                    total_deleted += 1
    if total_deleted > 0:
        logger.info("Deleted %d job file(s) from disk." % total_deleted)
    # returning a string so Flask can render it; calling functions that use the
    #  return value need to cast it back to int if they wish to use it as an int
    return str(total_deleted)
Deletes job files on disk if modification time exceeds expire time(s)
app/dalton.py