~edwargix/git.sr.ht

8b51f1bfa4cec0cba485dee96b1d9d0b1154eb67 — Drew DeVault 6 years ago 7a7b52c
Catch subprocess timeout on tarball prep
1 files changed, 10 insertions(+), 7 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +10 -7
@@ 351,13 351,16 @@ def patch(owner, repo, ref):
            abort(404)
        if isinstance(commit, pygit2.Tag):
            ref = git_repo.get(commit.target)
        subp = subprocess.run([
            "git",
            "--git-dir", repo.path,
            "format-patch",
            "--stdout", "-1",
            ref
        ], timeout=10, stdout=subprocess.PIPE, stderr=sys.stderr)
        try:
            subp = subprocess.run([
                "git",
                "--git-dir", repo.path,
                "format-patch",
                "--stdout", "-1",
                ref
            ], timeout=10, stdout=subprocess.PIPE, stderr=sys.stderr)
        except subprocess.TimeoutExpired:
            return "Operation timed out", 500
        if subp.returncode != 0:
            return "Error preparing patch", 500
        return Response(subp.stdout, mimetype='text/plain')