diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-10 18:20:07 -0500 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-08-11 16:17:08 +0200 |
commit | 5d74a994ff3e67bb2d3a3e27828785eb6bda94d9 (patch) | |
tree | 3544312c42f058247f6b7635f5c60ad074325753 | |
parent | 0ac74ed7335927639e6d74f83ebc9010f77c6b1f (diff) |
Make package creation and update atomic
Add BEGIN and COMMIT statements where it makes sense to do so. This
allows the entire package creation or update process to be atomic and
not be seen until it is complete.
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r-- | web/html/pkgsubmit.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index f7f0dd4..64281c7 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -299,6 +299,7 @@ if ($uid): if (!$error) { $dbh = db_connect(); + db_query("BEGIN", $dbh); $q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'"; $result = db_query($q, $dbh); @@ -396,9 +397,12 @@ if ($uid): # If we just created this package, or it was an orphan and we # auto-adopted, add submitting user to the notification list. if (!$pdata || $pdata["MaintainerUID"] === NULL) { - pkg_notify(account_from_sid($_COOKIE["AURSID"]), array($packageID)); + pkg_notify(account_from_sid($_COOKIE["AURSID"], $dbh), array($packageID), true, $dbh); } + # Entire package creation process is atomic + db_query("COMMIT", $dbh); + header('Location: packages.php?ID=' . $packageID); } |