fix(admin): article delete only removes build file + DB row, never .md source
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2645,18 +2645,13 @@ async def articles_bulk():
|
||||
from ..content.routes import BUILD_DIR
|
||||
|
||||
rows = await fetch_all(
|
||||
f"SELECT id, slug, article_type FROM articles WHERE {where} LIMIT 5000",
|
||||
f"SELECT id, slug FROM articles WHERE {where} LIMIT 5000",
|
||||
tuple(where_params),
|
||||
)
|
||||
for a in rows:
|
||||
build_path = BUILD_DIR / f"{a['slug']}.html"
|
||||
if build_path.exists():
|
||||
build_path.unlink()
|
||||
# Only remove source .md for generated articles
|
||||
if a["article_type"] == "generated":
|
||||
md_path = Path("data/content/articles") / f"{a['slug']}.md"
|
||||
if md_path.exists():
|
||||
md_path.unlink()
|
||||
await execute(f"DELETE FROM articles WHERE {where}", tuple(where_params))
|
||||
from ..sitemap import invalidate_sitemap_cache
|
||||
invalidate_sitemap_cache()
|
||||
@@ -2702,18 +2697,13 @@ async def articles_bulk():
|
||||
from ..content.routes import BUILD_DIR
|
||||
|
||||
articles_rows = await fetch_all(
|
||||
f"SELECT id, slug, article_type FROM articles WHERE id IN ({placeholders})",
|
||||
f"SELECT id, slug FROM articles WHERE id IN ({placeholders})",
|
||||
tuple(article_ids),
|
||||
)
|
||||
for a in articles_rows:
|
||||
build_path = BUILD_DIR / f"{a['slug']}.html"
|
||||
if build_path.exists():
|
||||
build_path.unlink()
|
||||
# Only remove source .md for generated articles
|
||||
if a["article_type"] == "generated":
|
||||
md_path = Path("data/content/articles") / f"{a['slug']}.md"
|
||||
if md_path.exists():
|
||||
md_path.unlink()
|
||||
await execute(
|
||||
f"DELETE FROM articles WHERE id IN ({placeholders})",
|
||||
tuple(article_ids),
|
||||
@@ -2939,14 +2929,10 @@ async def article_delete(article_id: int):
|
||||
"""Delete an article."""
|
||||
article = await fetch_one("SELECT slug FROM articles WHERE id = ?", (article_id,))
|
||||
if article:
|
||||
# Clean up files
|
||||
from ..content.routes import BUILD_DIR
|
||||
build_path = BUILD_DIR / f"{article['slug']}.html"
|
||||
if build_path.exists():
|
||||
build_path.unlink()
|
||||
md_path = Path("data/content/articles") / f"{article['slug']}.md"
|
||||
if md_path.exists():
|
||||
md_path.unlink()
|
||||
|
||||
await execute("DELETE FROM articles WHERE id = ?", (article_id,))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user