ref: 0237ae12582923c2d34bbd866a339540909a995c
parent: 9f1f55d40192f27dec4cd6dc2a24631c8921db48
author: telephil9 <[email protected]>
date: Sun Jan 17 00:33:35 EST 2021
handle entry changes rrss does not use the date field when considering if an item has already been seen. This means that if an entry is updated, rrss won't pick it up again. We now include the date in the makeold()/isold() functions to fix this situation.
--- a/main.go
+++ b/main.go
@@ -64,15 +64,16 @@
return client.Do(req)
}
-func isold(link string, path string) bool {
+func isold(date time.Time, link string, path string) bool {
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDONLY, 0775)
if err != nil {
return true
}
defer file.Close()
+ s := fmt.Sprintf("%d_%s", date.Unix(), link);
scanner := bufio.NewScanner(file)
for scanner.Scan() {
- if strings.Contains(link, scanner.Text()) {
+ if strings.Contains(s, scanner.Text()) {
return true
}
}
@@ -79,7 +80,7 @@
return false
}
-func makeold(link string, path string) (int, error) {
+func makeold(date time.Time, link string, path string) (int, error) {
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0775)
defer f.Close()
check(err)
@@ -86,7 +87,8 @@
if link == "" {
link = "empty"
}
- return f.WriteString(link + "\n")
+ s := fmt.Sprintf("%d_%s", date.Unix(), link);
+ return f.WriteString(s + "\n")
}
func writef(dir, filename, content string) {
@@ -120,7 +122,7 @@
check(err)
}
}
- _, err := makeold(a.Link, links)
+ _, err := makeold(a.Date, a.Link, links)
check(err)
}
}
@@ -137,7 +139,7 @@
d := fmt.Sprintf("%s/%d", dest, len(n))
ensuredir(d)
writef(d, "index.md", fmt.Sprintf("%s\n===\n\n%s\n", a.Title, a.Content))
- _, err = makeold(a.Link, links)
+ _, err = makeold(a.Date, a.Link, links)
check(err)
}
}
@@ -196,7 +198,7 @@
return nil
}
for _, i := range feed.Items {
- if isold(i.Link, links) {
+ if isold(i.Date, i.Link, links) {
continue
}
a := Article{i.Title, i.Link, i.Date, conorsum(i), tags}