Browse Source

Add timestamp to snippet uuid hash

master
Dylan Baker 5 years ago
parent
commit
b971e6ef3c
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/snippet.rs

+ 6
- 2
src/snippet.rs View File

@@ -1,4 +1,4 @@
1
-use chrono::NaiveDateTime;
1
+use chrono::{Local, NaiveDateTime};
2 2
 use crypto::digest::Digest;
3 3
 use crypto::sha2::Sha256;
4 4
 use diesel::pg::PgConnection as PGC;
@@ -60,8 +60,12 @@ fn format_snippet(filetype: Option<String>, body: String) -> String {
60 60
 }
61 61
 
62 62
 fn generate_uuid(snippet: &ApiSnippet) -> String {
63
+    let current_timestamp = Local::now().to_string();
63 64
     let mut hasher = Sha256::new();
64
-    hasher.input_str(&format!("{}{}", snippet.title, snippet.body));
65
+    hasher.input_str(&format!(
66
+        "{}{}{}",
67
+        snippet.title, snippet.body, current_timestamp
68
+    ));
65 69
     hasher.result_str().to_string()
66 70
 }
67 71
 

Loading…
Cancel
Save