Skip to content

Commit e70a4c4

Browse files
committed
fix: clear cached content when feed URL changes
Also prepare release 0.3.8
1 parent 31a45aa commit e70a4c4

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## Unreleased
88

9+
## 0.3.8 - 2025-01-18
10+
### Fixed
11+
* Cached feed content and corresponding etags/last modified headers are now cleared when the URL of a feed entry is updated
12+
913
## 0.3.7 - 2023-04-08
1014
### Fixed
1115
* Remove potential race condition caused by using `RLock` instead of `Lock`

walrss/internal/db/db.go

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ func (f *Feed) CacheWithLastModified(lastModified, content string) {
6262
f.CachedContent = content
6363
}
6464

65+
func (f *Feed) ClearCache() {
66+
f.LastEtag = ""
67+
f.LastModified = ""
68+
f.CachedContent = ""
69+
}
70+
6571
type FeedSlice []*Feed
6672

6773
func (f FeedSlice) Len() int {

walrss/internal/http/edit.go

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ func (s *Server) editFeedItem(ctx *fiber.Ctx) error {
107107
feed.Name = ctx.FormValue("name")
108108
feed.URL = ctx.FormValue("url")
109109

110+
if urlChanged := feed.URL != ctx.FormValue("old-url"); urlChanged {
111+
feed.ClearCache()
112+
}
113+
110114
if err := core.UpdateFeed(s.state, feed); err != nil {
111115
return err
112116
}

walrss/internal/http/views/main.qtpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ <h1>My settings</h1>
186186
name="url"
187187
id="feed-{%s= id %}-url"
188188
value="{%j url %}"
189-
></td>
189+
><input type="hidden" name="old-url" value="{%j url %}"></td>
190190
<td>
191191
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
192192
<button

walrss/internal/http/views/main.qtpl.html.go

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)