mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-29 09:10:13 +02:00
Improve search.backends.sqlite retry logic
Retry with table creation should fail if it is attempted for a second time.
This commit is contained in:
@@ -129,14 +129,16 @@ def index(snapshot_id: str, texts: List[str]):
|
|||||||
"INSERT OR REPLACE INTO"
|
"INSERT OR REPLACE INTO"
|
||||||
f" {table}(rowid, {column}) VALUES ({SQLITE_BIND}, {SQLITE_BIND})",
|
f" {table}(rowid, {column}) VALUES ({SQLITE_BIND}, {SQLITE_BIND})",
|
||||||
[rowid, text])
|
[rowid, text])
|
||||||
# All statements succeeded; break retry loop
|
# All statements succeeded; return
|
||||||
break
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if str(e).startswith(f"no such table:"):
|
if str(e).startswith("no such table:") and retries > 0:
|
||||||
_create_tables()
|
_create_tables()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
raise RuntimeError("Failed to create tables for SQLite FTS5 search")
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def search(text: str) -> List[str]:
|
def search(text: str) -> List[str]:
|
||||||
table = _escape_sqlite3_identifier(FTS_TABLE)
|
table = _escape_sqlite3_identifier(FTS_TABLE)
|
||||||
|
Reference in New Issue
Block a user