~rjarry/dlrepo

47ef1c4d24805112145f5201dbbe8658ee6292ba — Julien Floret 10 months ago 3837eab
fmt: refuse deletion if job is locked

A format should not be deleted in a locked job.

Fixes: 6de1f15cfcf8 ("format: add delete method")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
Acked-by: Robin Jarry <robin@jarry.cc>
1 files changed, 4 insertions(+), 2 deletions(-)

M dlrepo/views/fmt.py
M dlrepo/views/fmt.py => dlrepo/views/fmt.py +4 -2
@@ 192,12 192,14 @@ def _get_format(
                .get_format(match_info["format"])
            )
        else:
            fmt = (
            job = (
                repo.get_branch(match_info["branch"])
                .get_tag(match_info["tag"], access_cb)
                .get_job(match_info["job"])
                .get_format(match_info["format"])
            )
            fmt = job.get_format(match_info["format"])
            if delete and job.is_locked():
                raise web.HTTPBadRequest(reason="Cannot delete format: job is locked")
    except FileNotFoundError as e:
        raise web.HTTPNotFound() from e
    if not fmt.exists():