diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2016-08-09 14:46:08 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-08-10 20:14:17 +0200 |
commit | 936ee66f1e3e387d24f9bb4f5d00071c15c9f3bd (patch) | |
tree | 2368ff886dfa550d329948383640bf00557af813 /git-interface/git-update.py | |
parent | ac6b09172483fae46bc643fa80da71961682965f (diff) | |
download | aur-936ee66f1e3e387d24f9bb4f5d00071c15c9f3bd.tar.gz aur-936ee66f1e3e387d24f9bb4f5d00071c15c9f3bd.tar.xz |
Lazy-add new package bases
Create new package bases just before saving package metadata. This
protects from stray package bases left behind when new packages are
rejected, e.g. when the user tries to push a package that is available
from the official repositories already.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface/git-update.py')
-rwxr-xr-x | git-interface/git-update.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/git-interface/git-update.py b/git-interface/git-update.py index e6f6410a..40d834d8 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -58,6 +58,25 @@ def parse_dep(depstring): return (depname, depcond) +def create_pkgbase(conn, pkgbase, user): + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", [user]) + userid = cur.fetchone()[0] + + now = int(time.time()) + cur = conn.execute("INSERT INTO PackageBases (Name, SubmittedTS, " + + "ModifiedTS, SubmitterUID, MaintainerUID) VALUES " + + "(?, ?, ?, ?, ?)", [pkgbase, now, now, userid, userid]) + pkgbase_id = cur.lastrowid + + cur = conn.execute("INSERT INTO PackageNotifications " + + "(PackageBaseID, UserID) VALUES (?, ?)", + [pkgbase_id, userid]) + + conn.commit() + + return pkgbase_id + + def save_metadata(metadata, conn, user): # Obtain package base ID and previous maintainer. pkgbase = metadata['pkgbase'] @@ -362,6 +381,10 @@ for pkgname in srcinfo.utils.get_package_names(metadata): if cur.fetchone()[0] > 0: die('cannot overwrite package: {:s}'.format(pkgname)) +# Create a new package base if it does not exist yet. +if pkgbase_id == 0: + pkgbase_id = create_pkgbase(conn, pkgbase, user) + # Store package base details in the database. save_metadata(metadata, conn, user) |