aboutsummaryrefslogtreecommitdiffstats
path: root/walrss
diff options
context:
space:
mode:
authorAKP <abi@tdpain.net>2025-01-18 12:48:45 +0000
committerAKP <abi@tdpain.net>2025-01-18 12:49:58 +0000
commite70a4c43cd2711e4b6457dda2c207ddf2d3cb586 (patch)
tree6e93098db7dd68cdbe86eea8c0e02d42b6ebf567 /walrss
parent31a45aa27ad50c68b6e8e2b7c949b4d2ae12684c (diff)
fix: clear cached content when feed URL changes
Also prepare release 0.3.8
Diffstat (limited to 'walrss')
-rw-r--r--walrss/internal/db/db.go6
-rw-r--r--walrss/internal/http/edit.go4
-rw-r--r--walrss/internal/http/views/main.qtpl.html2
-rw-r--r--walrss/internal/http/views/main.qtpl.html.go4
4 files changed, 14 insertions, 2 deletions
diff --git a/walrss/internal/db/db.go b/walrss/internal/db/db.go
index 604ef91..880644f 100644
--- a/walrss/internal/db/db.go
+++ b/walrss/internal/db/db.go
@@ -62,6 +62,12 @@ func (f *Feed) CacheWithLastModified(lastModified, content string) {
f.CachedContent = content
}
+func (f *Feed) ClearCache() {
+ f.LastEtag = ""
+ f.LastModified = ""
+ f.CachedContent = ""
+}
+
type FeedSlice []*Feed
func (f FeedSlice) Len() int {
diff --git a/walrss/internal/http/edit.go b/walrss/internal/http/edit.go
index 657989a..f126710 100644
--- a/walrss/internal/http/edit.go
+++ b/walrss/internal/http/edit.go
@@ -107,6 +107,10 @@ func (s *Server) editFeedItem(ctx *fiber.Ctx) error {
feed.Name = ctx.FormValue("name")
feed.URL = ctx.FormValue("url")
+ if urlChanged := feed.URL != ctx.FormValue("old-url"); urlChanged {
+ feed.ClearCache()
+ }
+
if err := core.UpdateFeed(s.state, feed); err != nil {
return err
}
diff --git a/walrss/internal/http/views/main.qtpl.html b/walrss/internal/http/views/main.qtpl.html
index 191f8f7..a6b5843 100644
--- a/walrss/internal/http/views/main.qtpl.html
+++ b/walrss/internal/http/views/main.qtpl.html
@@ -186,7 +186,7 @@
name="url"
id="feed-{%s= id %}-url"
value="{%j url %}"
- ></td>
+ ><input type="hidden" name="old-url" value="{%j url %}"></td>
<td>
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
<button
diff --git a/walrss/internal/http/views/main.qtpl.html.go b/walrss/internal/http/views/main.qtpl.html.go
index e078f7d..f9c5dc0 100644
--- a/walrss/internal/http/views/main.qtpl.html.go
+++ b/walrss/internal/http/views/main.qtpl.html.go
@@ -298,7 +298,9 @@ func StreamRenderFeedEditRow(qw422016 *qt422016.Writer, id, name, url string) {
value="`)
qw422016.E().J(url)
qw422016.N().S(`"
- ></td>
+ ><input type="hidden" name="old-url" value="`)
+ qw422016.E().J(url)
+ qw422016.N().S(`"></td>
<td>
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
<button