1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use chrono::prelude::*;
use crev_data::proof::Content;
use std::path::PathBuf;
fn type_name(content: &Content) -> (&str, Option<&str>) {
match content {
Content::Trust(_) => ("trust", None),
Content::Code(_) => ("reviews", Some("code")),
Content::Package(_) => ("reviews", Some("packages")),
}
}
pub(crate) fn rel_package_path(content: &Content) -> PathBuf {
rel_store_path(content)
}
pub(crate) fn rel_store_path(content: &Content) -> PathBuf {
let (type_name, type_subname) = type_name(content);
let date = content
.date()
.with_timezone(&Utc)
.format("%Y-%m")
.to_string();
let path = PathBuf::from(content.author_id().to_string()).join(type_name);
path.join(if let Some(type_subname) = type_subname {
format!("{}-{}", date, type_subname)
} else {
date
})
.with_extension("proof.crev")
}