소스 검색

Add timestamp to snippet uuid hash

master
Dylan Baker 5 년 전
부모
커밋
b971e6ef3c
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6
    2
      src/snippet.rs

+ 6
- 2
src/snippet.rs 파일 보기

@@ -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…
취소
저장