From 51b00944308868103ad86657407050c2b2980711 Mon Sep 17 00:00:00 2001 From: Sulthan Zaki Date: Tue, 11 Aug 2026 13:02:18 +0700 Subject: [PATCH] Tighten lnw comments and log form after review (#87) Cross-reference lnwChapterRe from the function doc instead of restating its rationale, drop the redundant '; skipping' from the fail-closed log to match the package's bare verb:detail form, and reword the truncation comment so the logged body length is not described as a code-made distinction. --- backend/internal/latest/sites.go | 12 ++++-------- backend/internal/latest/sites_test.go | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/backend/internal/latest/sites.go b/backend/internal/latest/sites.go index 7b2f2f5..0c354ec 100644 --- a/backend/internal/latest/sites.go +++ b/backend/internal/latest/sites.go @@ -98,11 +98,7 @@ const lnwCommentMarker = "wpd-threads" // such guarantee — demonicChapterRe matches any chaptered.php?manga= anchor // with no per-series scoping, because the stored series_id for demonic is a // slug, not the numeric id the URL carries, so it cannot easily be scoped. -// lightnovelworld is unscoped for a stronger reason: its chapter addresses -// carry the Chapter Slug, which is not the Series identity, so no stored-slug -// pattern can cover a Series' whole list (see lnwChapterRe). Instead of -// scoping, its branch scans only the body before the comment thread marker and -// skips the page when the marker is absent. +// lightnovelworld is unscoped and body-truncated instead — see lnwChapterRe. func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) { var re *regexp.Regexp switch site { @@ -151,11 +147,11 @@ func latestChapterFrom(site, seriesURL, body string) (latestChapter, bool) { // page any visitor can write to, so the scan never reads past it (see // lnwChapterRe). A body without the marker is skipped, never scanned // whole — a redesign must degrade into staleness, not into a wrong - // shared value. The body length distinguishes a genuine markup change - // from a body the size cap cut short. + // shared value; the logged body length tells a markup change from a + // body the size cap cut short. i := strings.Index(body, lnwCommentMarker) if i < 0 { - log.Printf("latest poll %q: no %s marker in %d bytes; skipping", seriesURL, lnwCommentMarker, len(body)) + log.Printf("latest poll %q: no %s marker in %d bytes", seriesURL, lnwCommentMarker, len(body)) return latestChapter{}, false } body = body[:i] diff --git a/backend/internal/latest/sites_test.go b/backend/internal/latest/sites_test.go index 6afd0af..d665b25 100644 --- a/backend/internal/latest/sites_test.go +++ b/backend/internal/latest/sites_test.go @@ -414,8 +414,8 @@ func TestLatestChapterFrom(t *testing.T) { // Stored before the slug split, so the address carries the ...-not // Chapter Slug; the 100-423 block under the other slug must still win. // The body is the chapter-list portion of lnwSeriesFixture with the - // comment block omitted (that is the next case's job); the marker is - // kept, because a body without it is skipped, not scanned. + // comment block omitted; the marker is kept, because a body without it + // is skipped, not scanned. { name: "lightnovelworld max spans both chapter slugs", site: "lightnovelworld",