Improve change detection and enhance content extraction logic

This commit is contained in:
2026-06-15 01:15:35 +02:00
parent 9a4f4c7c2b
commit ec08af4640
3 changed files with 10 additions and 2 deletions

View File

@@ -1388,6 +1388,8 @@ async def refresh_library_website(slug: str, item_id: str):
source_path = Path(str(entry.get("path") or ""))
previous_hash = str(entry.get("sha256") or "")
previous_title = str(entry.get("title") or "")
previous_url = str(entry.get("url") or "")
_write_text_atomic(source_path, str(snapshot["text"]))
next_hash = _sha256_file(source_path)
entry.update({
@@ -1407,7 +1409,7 @@ async def refresh_library_website(slug: str, item_id: str):
entry["name"] = title
job_id = None
changed = next_hash != previous_hash
changed = next_hash != previous_hash or str(entry.get("title") or "") != previous_title or str(entry.get("url") or "") != previous_url
if changed:
_mark_entry_pending(entry)
job_id = await _save_library_change(slug, data)

View File

@@ -263,6 +263,9 @@ async def fetch_website_snapshot(url: str) -> Dict[str, Any]:
text = clean_text(html)
if len(text.strip()) < 80:
raise ValueError("The website did not contain enough readable text to save.")
if not title:
first_line = next((line.strip() for line in text.splitlines() if line.strip()), "")
title = re.sub(r"^[#>*_`\-\s]+", "", first_line).strip()[:240]
return {
"requested_url": requested_url,

View File

@@ -108,7 +108,10 @@ export default function LibraryManager({ apiBase, library, jobs, onRefresh }) {
})
}
useEffect(() => () => clearToasts(), [])
useEffect(() => () => {
toastTimeoutsRef.current.forEach(timeoutId => clearTimeout(timeoutId))
toastTimeoutsRef.current.clear()
}, [])
function closeForm() {
setFormMode(null)