mirror of
https://github.com/YGGverse/pulsarss.git
synced 2026-04-01 01:25:30 +00:00
skip not relevant records from index.gmi
This commit is contained in:
parent
925ae08bf7
commit
aebc850de1
2 changed files with 32 additions and 29 deletions
30
src/path.rs
30
src/path.rs
|
|
@ -2,8 +2,8 @@ use std::error::Error;
|
|||
use std::path::MAIN_SEPARATOR;
|
||||
|
||||
pub struct Path {
|
||||
file: String,
|
||||
path: String,
|
||||
pub item: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
impl Path {
|
||||
|
|
@ -12,27 +12,27 @@ impl Path {
|
|||
pub fn build(base: &str, pub_date: &str, mkdir: bool) -> Result<Path, Box<dyn Error>> {
|
||||
use chrono::{DateTime, Datelike, Timelike};
|
||||
|
||||
let date_time = DateTime::parse_from_rfc2822(pub_date)?;
|
||||
let time = DateTime::parse_from_rfc2822(pub_date)?;
|
||||
|
||||
let file = format!(
|
||||
let item = format!(
|
||||
"{:02}-{:02}-{:02}.gmi",
|
||||
date_time.hour(),
|
||||
date_time.minute(),
|
||||
date_time.second()
|
||||
time.hour(),
|
||||
time.minute(),
|
||||
time.second()
|
||||
);
|
||||
|
||||
let path = format!(
|
||||
"{base}{MAIN_SEPARATOR}{:02}{MAIN_SEPARATOR}{:02}{MAIN_SEPARATOR}{:02}",
|
||||
date_time.year(),
|
||||
date_time.month(),
|
||||
date_time.day()
|
||||
time.year(),
|
||||
time.month(),
|
||||
time.day()
|
||||
);
|
||||
|
||||
if mkdir {
|
||||
std::fs::create_dir_all(&path)?;
|
||||
}
|
||||
|
||||
Ok(Path { file, path })
|
||||
Ok(Path { item, path })
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
@ -41,11 +41,7 @@ impl Path {
|
|||
format!("{}{MAIN_SEPARATOR}index.gmi", self.path)
|
||||
}
|
||||
|
||||
pub fn filepath(&self) -> String {
|
||||
format!("{}{MAIN_SEPARATOR}{}", self.path, self.file)
|
||||
}
|
||||
|
||||
pub fn filename(&self) -> &str {
|
||||
&self.file
|
||||
pub fn item(&self) -> String {
|
||||
format!("{}{MAIN_SEPARATOR}{}", self.path, self.item)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue