mirror of
https://github.com/xvxx/phd
synced 2024-11-10 13:10:23 +00:00
dont ensure
This commit is contained in:
parent
f0457bfccc
commit
1465c5beed
@ -69,11 +69,9 @@ where
|
||||
} else {
|
||||
// check for index.gph if we're looking for dir
|
||||
let mut index = path.clone();
|
||||
ensure_trailing_slash(&mut index);
|
||||
index.push_str("index.gph");
|
||||
index.push_str("/index.gph");
|
||||
if Path::new(&index).exists() {
|
||||
ensure_trailing_slash(&mut req.selector);
|
||||
req.selector.push_str("index.gph");
|
||||
req.selector.push_str("/index.gph");
|
||||
return write_gophermap(w, req);
|
||||
}
|
||||
}
|
||||
@ -137,7 +135,7 @@ where
|
||||
continue;
|
||||
}
|
||||
let mut path = rel_path.clone();
|
||||
ensure_trailing_slash(&mut path);
|
||||
path.push('/');
|
||||
path.push_str(&file_name.to_string_lossy());
|
||||
menu.write_entry(
|
||||
file_type(&entry),
|
||||
@ -175,9 +173,7 @@ where
|
||||
&'a W: Write,
|
||||
{
|
||||
let path = req.file_path();
|
||||
println!("write_gophermap: {:?}", path);
|
||||
let file = File::open(&path)?;
|
||||
println!("write_gophermap: {:?}", path);
|
||||
let reader = BufReader::new(file);
|
||||
for line in reader.lines() {
|
||||
let mut line = line?.trim_end_matches("\r\n").to_string();
|
||||
@ -223,9 +219,3 @@ fn file_type(dir: &fs::DirEntry) -> ItemType {
|
||||
ItemType::Error
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_trailing_slash(s: &mut String) {
|
||||
if !s.ends_with('/') {
|
||||
s.push('/');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user