summaryrefslogtreecommitdiffstats
path: root/git-interface/git-update.py
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-08-03 01:59:37 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-08-05 11:25:51 +0200
commit2cd69bf66d244c7d438992aff1a03ea52cdba819 (patch)
tree35fe3a04cfec7380cd8aa09dda4cfc9c9b9c1495 /git-interface/git-update.py
parent87f5f1b407fee29412c761e6f1484f51fae86eda (diff)
downloadaurweb-2cd69bf66d244c7d438992aff1a03ea52cdba819.tar.xz
git-update: Make maximum blob size configurable
Support setting the maximum blob size in the configuration file. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface/git-update.py')
-rwxr-xr-xgit-interface/git-update.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/git-interface/git-update.py b/git-interface/git-update.py
index 68f7387..7aace9b 100755
--- a/git-interface/git-update.py
+++ b/git-interface/git-update.py
@@ -25,6 +25,19 @@ notify_cmd = config.get('notifications', 'notify-cmd')
repo_path = config.get('serve', 'repo-path')
repo_regex = config.get('serve', 'repo-regex')
+max_blob_size = config.getint('update', 'max-blob-size')
+
+
+def size_humanize(num):
+ for unit in ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB']:
+ if abs(num) < 2048.0:
+ if isinstance(num, int):
+ return "{}{}".format(num, unit)
+ else:
+ return "{:.2f}{}".format(num, unit)
+ num /= 1024.0
+ return "{:.2f}{}".format(num, 'YiB')
+
def extract_arch_fields(pkginfo, field):
values = []
@@ -254,8 +267,8 @@ for commit in walker:
die_commit("not a blob object: {:s}".format(treeobj),
str(commit.id))
- if blob.size > 250000:
- die_commit("maximum blob size (250kB) exceeded", str(commit.id))
+ if blob.size > max_blob_size:
+ die_commit("maximum blob size ({:s}) exceeded".format(size_humanize(max_blob_size)), str(commit.id))
metadata_raw = repo[commit.tree['.SRCINFO'].id].data.decode()
(metadata, errors) = srcinfo.parse.parse_srcinfo(metadata_raw)