mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-25 05:30:23 +00: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:
parent
8fe5faf4d0
commit
e0f8eeeaa7
1 changed files with 5 additions and 3 deletions
|
@ -129,14 +129,16 @@ def index(snapshot_id: str, texts: List[str]):
|
|||
"INSERT OR REPLACE INTO"
|
||||
f" {table}(rowid, {column}) VALUES ({SQLITE_BIND}, {SQLITE_BIND})",
|
||||
[rowid, text])
|
||||
# All statements succeeded; break retry loop
|
||||
break
|
||||
# All statements succeeded; return
|
||||
return
|
||||
except Exception as e:
|
||||
if str(e).startswith(f"no such table:"):
|
||||
if str(e).startswith("no such table:") and retries > 0:
|
||||
_create_tables()
|
||||
else:
|
||||
raise
|
||||
|
||||
raise RuntimeError("Failed to create tables for SQLite FTS5 search")
|
||||
|
||||
@enforce_types
|
||||
def search(text: str) -> List[str]:
|
||||
table = _escape_sqlite3_identifier(FTS_TABLE)
|
||||
|
|
Loading…
Reference in a new issue