Repos / pytaku / e48632c69a
commit e48632c69a0c2e35abc6b5b19d5d02cd2afb83c9
Author: Bùi Thành Nhân <hi@imnhan.com>
Date:   Sat Aug 15 11:36:55 2020 +0700

    bugfix: don't throw up on dupe follow

diff --git a/pyproject.toml b/pyproject.toml
index 2945695..dce411b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "pytaku"
-version = "0.2.19"
+version = "0.2.20"
 description = ""
 authors = ["Bùi Thành Nhân <hi@imnhan.com>"]
 license = "AGPL-3.0-only"
diff --git a/src/pytaku/persistence.py b/src/pytaku/persistence.py
index b651f75..7fba2d5 100644
--- a/src/pytaku/persistence.py
+++ b/src/pytaku/persistence.py
@@ -330,7 +330,8 @@ def set(key: str, value: str):
 def import_follows(user_id: int, site_title_pairs: List[Tuple[str, str]]):
     run_sql_many(
         """
-        INSERT INTO follow (user_id, site, title_id) VALUES (?, ?, ?);
+        INSERT INTO follow (user_id, site, title_id) VALUES (?, ?, ?)
+        ON CONFLICT DO NOTHING;
         """,
         ((user_id, site, title_id) for site, title_id in site_title_pairs),
     )