Parcourir la source

Add timestamp to snippet uuid hash

master
Dylan Baker il y a 5 ans
Parent
révision
b971e6ef3c
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6
    2
      src/snippet.rs

+ 6
- 2
src/snippet.rs Voir le fichier

1
-use chrono::NaiveDateTime;
1
+use chrono::{Local, NaiveDateTime};
2
 use crypto::digest::Digest;
2
 use crypto::digest::Digest;
3
 use crypto::sha2::Sha256;
3
 use crypto::sha2::Sha256;
4
 use diesel::pg::PgConnection as PGC;
4
 use diesel::pg::PgConnection as PGC;
60
 }
60
 }
61
 
61
 
62
 fn generate_uuid(snippet: &ApiSnippet) -> String {
62
 fn generate_uuid(snippet: &ApiSnippet) -> String {
63
+    let current_timestamp = Local::now().to_string();
63
     let mut hasher = Sha256::new();
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
     hasher.result_str().to_string()
69
     hasher.result_str().to_string()
66
 }
70
 }
67
 
71
 

Chargement…
Annuler
Enregistrer