mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: --force drops vec0 tables instead of ChromaDB directory
Replace shutil.rmtree on the ChromaDB path with DROP TABLE IF EXISTS on vec0 virtual tables and their companion meta tables. Force rebuild now opens paperforge.db and drops vec_fulltext, vec_body, vec_objects, vec_fulltext_meta, vec_body_meta, and vec_objects_meta. Also replaced the remaining get_vector_db_path reference in the error handler with get_memory_db_path. Removed get_vector_db_path import from embed.py since it is no longer used in active control flow.
This commit is contained in:
parent
59581c72bf
commit
11eb2946d9
1 changed files with 17 additions and 12 deletions
|
|
@ -12,7 +12,6 @@ from paperforge.core.result import PFError, PFResult
|
|||
from paperforge.embedding import (
|
||||
delete_paper_vectors,
|
||||
get_embed_status,
|
||||
get_vector_db_path,
|
||||
mark_vector_build_state,
|
||||
read_vector_build_state,
|
||||
)
|
||||
|
|
@ -325,16 +324,22 @@ def run(args: argparse.Namespace) -> int:
|
|||
_force_rebuild = args.force or (resume is False and getattr(args, "resume", False))
|
||||
if _force_rebuild:
|
||||
_gc.collect()
|
||||
db_path = get_vector_db_path(vault)
|
||||
if db_path.exists():
|
||||
import shutil
|
||||
|
||||
shutil.rmtree(str(db_path), ignore_errors=True)
|
||||
if db_path.exists():
|
||||
import time
|
||||
|
||||
time.sleep(0.5)
|
||||
shutil.rmtree(str(db_path), ignore_errors=True)
|
||||
_db_path = get_memory_db_path(vault)
|
||||
if _db_path.exists():
|
||||
_conn = get_connection(_db_path)
|
||||
try:
|
||||
from paperforge.memory.db import ensure_vec_extension
|
||||
from paperforge.memory.schema import ensure_schema
|
||||
ensure_vec_extension(_conn)
|
||||
ensure_schema(_conn)
|
||||
for _t in ("vec_fulltext", "vec_body", "vec_objects",
|
||||
"vec_fulltext_meta", "vec_body_meta", "vec_objects_meta"):
|
||||
_conn.execute(f'DROP TABLE IF EXISTS "{_t}"')
|
||||
_conn.commit()
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
_conn.close()
|
||||
|
||||
mark_vector_build_state(
|
||||
vault,
|
||||
|
|
@ -579,7 +584,7 @@ def run(args: argparse.Namespace) -> int:
|
|||
deps_installed=True,
|
||||
deps_missing=None,
|
||||
py_version=sys.version.split()[0],
|
||||
db_exists=get_vector_db_path(vault).exists(),
|
||||
db_exists=get_memory_db_path(vault).exists(),
|
||||
chunk_count=_actual,
|
||||
body_chunk_count=0,
|
||||
object_chunk_count=0,
|
||||
|
|
|
|||
Loading…
Reference in a new issue