Fix size limit not being applied to Git releases

Fixes #495
This commit is contained in:
rubenwardy 2023-12-15 16:19:02 +00:00
parent a29345bd10
commit c6a59701be
2 changed files with 12 additions and 4 deletions

@ -230,12 +230,17 @@ def make_vcs_release(self, id, branch):
post_release_check_update(self, release, repo.working_tree_dir)
filename = random_string(10) + ".zip"
destPath = os.path.join(app.config["UPLOAD_DIR"], filename)
dest_path = os.path.join(app.config["UPLOAD_DIR"], filename)
assert(not os.path.isfile(destPath))
assert not os.path.isfile(dest_path)
archiver = GitArchiver(prefix=release.package.name, force_sub=True, main_repo_abspath=repo.working_tree_dir)
archiver.create(destPath)
assert(os.path.isfile(destPath))
archiver.create(dest_path)
assert os.path.isfile(dest_path)
file_stats = os.stat(dest_path)
if file_stats.st_size / (1024 * 1024) > 100:
os.remove(dest_path)
raise TaskError("The .zip file created from Git is too large - needs to be less than 100MB")
release.url = "/uploads/" + filename
release.task_id = None

3
utils/common.sh Normal file

@ -0,0 +1,3 @@
container() {
contentdb-$1
}