[aur-dev] [PATCH 1/3] git-update: Fix some issues reported by pyflakes
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-update.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 41b38a6..5fc5562 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -167,11 +167,13 @@ def save_metadata(metadata, db, cur, user): "PackageBaseID = %s AND UserID = %s", [pkgbase_id, user_id]) if cur.fetchone()[0] == 0: - cur.execute("INSERT INTO PackageNotifications (PackageBaseID, UserID) " + - "VALUES (%s, %s)", [pkgbase_id, user_id]) + cur.execute("INSERT INTO PackageNotifications " + + "(PackageBaseID, UserID) VALUES (%s, %s)", + [pkgbase_id, user_id]) db.commit() + def update_notify(db, cur, user, pkgbase_id): # Obtain the user ID of the new maintainer. cur.execute("SELECT ID FROM Users WHERE Username = %s", [user]) @@ -180,6 +182,7 @@ def update_notify(db, cur, user, pkgbase_id): # Execute the notification script. subprocess.Popen((notify_cmd, 'update', str(user_id), str(pkgbase_id))) + def die(msg): sys.stderr.write("error: {:s}\n".format(msg)) exit(1) -- 2.9.2
Instead of looking up the account type of the current user again, use the AUR_PRIVILEGED environment variable to check whether the user is allowed to perform non-fast-forward ref updates. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-update.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 5fc5562..68f7387 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -226,14 +226,11 @@ db = mysql.connector.connect(host=aur_db_host, user=aur_db_user, cur = db.cursor() # Detect and deny non-fast-forwards. -if sha1_old != "0000000000000000000000000000000000000000": +if sha1_old != "0000000000000000000000000000000000000000" and not privileged: walker = repo.walk(sha1_old, pygit2.GIT_SORT_TOPOLOGICAL) walker.hide(sha1_new) if next(walker, None) is not None: - cur.execute("SELECT AccountTypeID FROM Users WHERE UserName = %s ", - [user]) - if cur.fetchone()[0] == 1: - die("denying non-fast-forward (you should pull first)") + die("denying non-fast-forward (you should pull first)") # Prepare the walker that validates new commits. walker = repo.walk(sha1_new, pygit2.GIT_SORT_TOPOLOGICAL) -- 2.9.2
Support setting the maximum blob size in the configuration file. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- conf/config.proto | 3 +++ git-interface/git-update.py | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/conf/config.proto b/conf/config.proto index d5778a0..543c3ca 100644 --- a/conf/config.proto +++ b/conf/config.proto @@ -56,6 +56,9 @@ git-shell-cmd = /usr/bin/git-shell git-update-cmd = /srv/http/aurweb/git-interface/git-update.py ssh-cmdline = ssh aur@aur.archlinux.org +[update] +max-blob-size = 256000 + [aurblup] db-path = /srv/http/aurweb/aurblup/ sync-dbs = core extra community multilib testing community-testing 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) -- 2.9.2
participants (1)
-
Lukas Fleischer