This commit is contained in:
TriMill 2022-11-29 08:57:31 -05:00
parent b0bab11be7
commit daf5292826
4 changed files with 8 additions and 8 deletions

View File

@ -9,9 +9,9 @@ pub struct HookData {
pub pub_date: String,
}
pub fn run_hook(hook: String, hookdata: Vec<HookData>) -> Result<(), std::io::Error> {
pub fn run_hook(hook: &str, hookdata: Vec<HookData>) -> Result<(), std::io::Error> {
for data in hookdata {
Command::new(hook.clone())
Command::new(hook)
.env("TITLE", data.title)
.env("TITLE_FMT", data.title_fmt)
.env("AUTHOR", data.author)

View File

@ -50,7 +50,7 @@ pub fn bundle_rss(state: &mut State, config: &Config) -> (Vec<HookData>, Channel
state.guids.insert(guid.value.clone());
let data = HookData {
title: item.title.as_ref().unwrap_or(&config.default_title).to_owned(),
title: item.title.as_ref().unwrap_or(&config.default_title).clone(),
title_fmt: item_title.clone(),
author: item.author.clone().unwrap(),
link: item.link.clone().unwrap_or_default(),

View File

@ -40,7 +40,7 @@ fn main() -> ExitCode {
let guids = load_guids().unwrap_or_default();
let state = State {
rss: "".into(),
rss: String::new(),
guids,
feeds: HashMap::new(),
status: None,
@ -66,7 +66,7 @@ fn main() -> ExitCode {
} else { None };
if let Some(hook) = &config.hook {
run_hook(hook.to_owned(), hookdata).unwrap();
run_hook(hook, hookdata).unwrap();
}
guard.status = status;
@ -92,7 +92,7 @@ fn load_config() -> Result<Config, Box<dyn std::error::Error>> {
fn load_guids() -> Result<HashSet<String>, Box<dyn std::error::Error>> {
let content = fs::read_to_string("guids")?;
Ok(content.split("\n").filter(|x| x.len() > 0).map(str::to_owned).collect())
Ok(content.split('\n').filter(|x| !x.is_empty()).map(str::to_owned).collect())
}
fn save_guids(guids: &HashSet<String>) -> Result<(), Box<dyn std::error::Error>> {

View File

@ -32,7 +32,7 @@ pub fn start(address: &str, thread_count: usize, state: Arc<Mutex<State>>) -> Ve
continue
}
};
let page = url.path().split("/").last().unwrap_or("");
let page = url.path().split('/').last().unwrap_or("");
let res = match page {
"rss.xml" => {
let guard = state.lock().unwrap();
@ -55,4 +55,4 @@ pub fn start(address: &str, thread_count: usize, state: Arc<Mutex<State>>) -> Ve
}
threads
}
}