[PATCH] aurblup: make provider updates more robust
Prevent from corner cases, such as failing unique key constraints when a provided package changes from lower case to upper case. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- aurweb/scripts/aurblup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aurweb/scripts/aurblup.py b/aurweb/scripts/aurblup.py index 1433173..a7d43f1 100755 --- a/aurweb/scripts/aurblup.py +++ b/aurweb/scripts/aurblup.py @@ -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() -- 2.20.1
On 1/21/19 2:33 PM, Lukas Fleischer wrote:
Prevent from corner cases, such as failing unique key constraints when a provided package changes from lower case to upper case.
What about: "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." I'm a big lover of manuscript-style commit messages :D and this makes it clearer *how* the patch intends to solve the problem.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- aurweb/scripts/aurblup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/aurweb/scripts/aurblup.py b/aurweb/scripts/aurblup.py index 1433173..a7d43f1 100755 --- a/aurweb/scripts/aurblup.py +++ b/aurweb/scripts/aurblup.py @@ -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()
-- Eli Schwartz Bug Wrangler and Trusted User
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 <eschwartz@archlinux.org> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- aurweb/scripts/aurblup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aurweb/scripts/aurblup.py b/aurweb/scripts/aurblup.py index 1433173..a7d43f1 100755 --- a/aurweb/scripts/aurblup.py +++ b/aurweb/scripts/aurblup.py @@ -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() -- 2.20.1
participants (2)
-
Eli Schwartz
-
Lukas Fleischer