diff --git a/src/job.rs b/src/job.rs index a39b343..d5978e9 100644 --- a/src/job.rs +++ b/src/job.rs @@ -169,10 +169,14 @@ impl Job { } let channel = self.channel.as_mut().unwrap(); let update_time = chrono::Utc::now(); + let mut guid = rss::Guid::default(); + guid.set_permalink(false); + guid.set_value(update_time.timestamp().to_string().as_str()); let item = rss::ItemBuilder::default() .title(format!("Update to '{}'", self.url)) .link(self.url.clone()) .pub_date(update_time.to_rfc2822()) + .guid(Some(guid)) .content(format!(r#" New content at {}:
@@ -282,4 +286,18 @@ output_file = ./src/job_example.rss
         assert_eq!(job.output_file.as_ref().unwrap().to_str().unwrap(), "./src/job_example.rss");
         assert_eq!(job.last_value().unwrap(), "Version 1.64.0");
     }
+
+    #[test]
+    fn new_updates_have_different_guids() {
+        let conf = Conf::get_default_conf();
+        let mut job = Job::new("example", "selector", &conf);
+        job.output_file = None;
+        job.update("update 1", "diff");
+        std::thread::sleep(Duration::new(1, 0));
+        job.update("update 2", "diff");
+        assert!(job.channel.as_ref().unwrap().items[0].guid.is_some());
+        assert!(job.channel.as_ref().unwrap().items[1].guid.is_some());
+        assert_ne!(job.channel.as_ref().unwrap().items[0].guid.as_ref().unwrap(),
+                   job.channel.as_ref().unwrap().items[1].guid.as_ref().unwrap());
+    }
 }