mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add support for MySQL transactions to aurblup.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
13bcc269ff
commit
a64cd12feb
2 changed files with 19 additions and 0 deletions
|
@ -66,11 +66,22 @@ blacklist_sync(alpm_list_t *pkgs)
|
||||||
{
|
{
|
||||||
alpm_list_t *r, *p;
|
alpm_list_t *r, *p;
|
||||||
|
|
||||||
|
#if MYSQL_USE_TRANSACTIONS
|
||||||
|
if (mysql_autocommit(c, 0))
|
||||||
|
mysql_die("failed to turn MySQL autocommit off: %s\n");
|
||||||
|
|
||||||
|
if (mysql_query(c, "START TRANSACTION;"))
|
||||||
|
mysql_die("failed to start MySQL transaction: %s\n");
|
||||||
|
|
||||||
|
if (mysql_query(c, "TRUNCATE TABLE PackageBlacklist;"))
|
||||||
|
mysql_die("failed to truncate MySQL table: %s\n");
|
||||||
|
#else
|
||||||
if (mysql_query(c, "LOCK TABLES PackageBlacklist WRITE;"))
|
if (mysql_query(c, "LOCK TABLES PackageBlacklist WRITE;"))
|
||||||
mysql_die("failed to lock MySQL table: %s\n");
|
mysql_die("failed to lock MySQL table: %s\n");
|
||||||
|
|
||||||
if (mysql_query(c, "DELETE FROM PackageBlacklist;"))
|
if (mysql_query(c, "DELETE FROM PackageBlacklist;"))
|
||||||
mysql_die("failed to clear MySQL table: %s\n");
|
mysql_die("failed to clear MySQL table: %s\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (r = pkgs; r; r = alpm_list_next(r)) {
|
for (r = pkgs; r; r = alpm_list_next(r)) {
|
||||||
pmpkg_t *pkg = alpm_list_getdata(r);
|
pmpkg_t *pkg = alpm_list_getdata(r);
|
||||||
|
@ -86,8 +97,13 @@ blacklist_sync(alpm_list_t *pkgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MYSQL_USE_TRANSACTIONS
|
||||||
|
if (mysql_query(c, "COMMIT;"))
|
||||||
|
mysql_die("failed to commit MySQL transaction: %s\n");
|
||||||
|
#else
|
||||||
if (mysql_query(c, "UNLOCK TABLES;"))
|
if (mysql_query(c, "UNLOCK TABLES;"))
|
||||||
mysql_die("failed to unlock MySQL tables: %s\n");
|
mysql_die("failed to unlock MySQL tables: %s\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_list_t *
|
alpm_list_t *
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#define CONFIG_KEY_PASSWD "AUR_db_pass"
|
#define CONFIG_KEY_PASSWD "AUR_db_pass"
|
||||||
#define CONFIG_KEY_DB "AUR_db_name"
|
#define CONFIG_KEY_DB "AUR_db_name"
|
||||||
|
|
||||||
|
/* unset this to use "LOCK TABLE" instead of transactions */
|
||||||
|
#define MYSQL_USE_TRANSACTIONS 1
|
||||||
|
|
||||||
/* libalpm options */
|
/* libalpm options */
|
||||||
#define ALPM_DBPATH "/var/lib/aurblup/"
|
#define ALPM_DBPATH "/var/lib/aurblup/"
|
||||||
#define ALPM_MIRROR "ftp://mirrors.kernel.org/archlinux/%s/os/i686"
|
#define ALPM_MIRROR "ftp://mirrors.kernel.org/archlinux/%s/os/i686"
|
||||||
|
|
Loading…
Add table
Reference in a new issue