Commit 44af2b43 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

aurblup: make provider updates more robust



Reverse the order of deletion and addition so that deletion comes first.
This prevents corner cases such as failing unique key constraints when a
provided package changes from lower case to upper case and the old name
is not yet gone.
Helped-by: Eli Schwartz's avatarEli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent 042f3f26
......@@ -39,13 +39,13 @@ def main():
cur = conn.execute("SELECT Name, Provides FROM OfficialProviders")
oldproviders = set(cur.fetchall())
for pkg, provides in oldproviders.difference(providers):
conn.execute("DELETE FROM OfficialProviders "
"WHERE Name = ? AND Provides = ?", [pkg, provides])
for pkg, provides in providers.difference(oldproviders):
repo = repomap[(pkg, provides)]
conn.execute("INSERT INTO OfficialProviders (Name, Repo, Provides) "
"VALUES (?, ?, ?)", [pkg, repo, provides])
for pkg, provides in oldproviders.difference(providers):
conn.execute("DELETE FROM OfficialProviders "
"WHERE Name = ? AND Provides = ?", [pkg, provides])
conn.commit()
conn.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment