From 4defb1dfe58c6fd27c5e851c453e7714fa943417 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 2 Oct 2018 06:43:04 -0400 Subject: [PATCH] Improvements to archive generation Use a randomized path and re-raise exceptions for debugging use --- gitsrht/blueprints/repo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index ee69596..65e8e99 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -1,3 +1,4 @@ +import binascii import os import pygit2 import pygments @@ -190,7 +191,7 @@ def archive(owner, repo, ref): git_repo = CachedRepository(repo.path) commit, ref = lookup_ref(git_repo, ref) - path = f"/tmp/{commit.id.hex}.tar.gz" + path = f"/tmp/{commit.id.hex}{binascii.hexlify(os.urandom(8)}.tar.gz" try: args = [ "git", @@ -208,7 +209,7 @@ def archive(owner, repo, ref): os.unlink(path) except: pass - return "Error preparing archive", 500 + raise if subp.returncode != 0: print(subp.stdout, subp.stderr) -- 2.38.4