mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
0ac74ed733
commit
5d74a994ff
1 changed files with 5 additions and 1 deletions
|
@ -299,6 +299,7 @@ if ($uid):
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
|
|
||||||
$dbh = db_connect();
|
$dbh = db_connect();
|
||||||
|
db_query("BEGIN", $dbh);
|
||||||
|
|
||||||
$q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'";
|
$q = "SELECT * FROM Packages WHERE Name = '" . mysql_real_escape_string($new_pkgbuild['pkgname']) . "'";
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
|
@ -396,9 +397,12 @@ if ($uid):
|
||||||
# If we just created this package, or it was an orphan and we
|
# If we just created this package, or it was an orphan and we
|
||||||
# auto-adopted, add submitting user to the notification list.
|
# auto-adopted, add submitting user to the notification list.
|
||||||
if (!$pdata || $pdata["MaintainerUID"] === NULL) {
|
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);
|
header('Location: packages.php?ID=' . $packageID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue