ticket #68 attempt 1

This commit is contained in:
Typosaurus 2026-07-19 22:55:47 +00:00
parent 32314fc6d6
commit 35e79ba8c7
2 changed files with 17 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -463,11 +463,15 @@ def delete_node(project_uid: str, raw_path: str, deleted_by: str = "system") ->
if node is None:
raise ProjectFileError(f"'{path}' does not exist")
stamp = _now()
for row in _descendants(project_uid, path):
rows = _descendants(project_uid, path)
for row in rows:
_table().update(
{"uid": row["uid"], "deleted_at": stamp, "deleted_by": deleted_by},
["uid"],
)
for row in rows:
if row.get("is_binary"):
_unlink_blob(row)
def soft_delete_all_project_files(project_uid: str, deleted_by: str) -> None:
@ -578,9 +582,11 @@ def _export_node(row: dict, dest: Path) -> None:
if target.is_symlink():
target.unlink()
if row.get("is_binary") and row.get("stored_name") and row.get("directory"):
shutil.copyfile(
PROJECT_FILES_DIR / row["directory"] / row["stored_name"], target
)
src = PROJECT_FILES_DIR / row["directory"] / row["stored_name"]
try:
shutil.copyfile(src, target)
except (FileNotFoundError, OSError):
logger.warning("Blob file missing during export: %s", src)
else:
target.write_text(row.get("content") or "", encoding="utf-8")
@ -707,9 +713,12 @@ def export_to_dir(project_uid: str, subpath: str, dest_dir) -> int:
if target.is_symlink() or target.is_file():
target.unlink()
if row.get("is_binary") and row.get("stored_name") and row.get("directory"):
shutil.copyfile(
PROJECT_FILES_DIR / row["directory"] / row["stored_name"], target
)
src = PROJECT_FILES_DIR / row["directory"] / row["stored_name"]
try:
shutil.copyfile(src, target)
except (FileNotFoundError, OSError):
logger.warning("Blob file missing: %s", src)
continue
else:
target.write_text(row.get("content") or "", encoding="utf-8")
written += 1