Quick patch:

- Changed 302 responses to 200 where needed
- Fixed a bug where expiring pastas cause MicroBin to crahs
- Fixed a bug where water.css didn't have the correct MIME type
- Fixed a bug where missing doctype declaration caused styling issues in Firefox
This commit is contained in:
Daniel Szabo 2022-06-04 21:50:34 +01:00
parent 35d4df2cb8
commit be3ac27920
10 changed files with 32 additions and 25 deletions

View file

@ -3,7 +3,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use linkify::{LinkFinder, LinkKind};
use std::fs;
use crate::Pasta;
use crate::{dbio, Pasta};
pub fn remove_expired(pastas: &mut Vec<Pasta>) {
// get current time - this will be needed to check which pastas have expired
@ -22,17 +22,25 @@ pub fn remove_expired(pastas: &mut Vec<Pasta>) {
true
} else {
// remove the file itself
fs::remove_file(format!("./pasta_data/{}/{}", p.id_as_animals(), p.file))
.expect(&*format!("Failed to delete file {}!", p.file));
match fs::remove_file(format!("./pasta_data/{}/{}", p.id_as_animals(), p.file)) {
Ok(_) => {}
Err(_) => {
log::error!("Failed to delete file {}!", p.file)
}
}
// and remove the containing directory
fs::remove_dir(format!("./pasta_data/{}/", p.id_as_animals())).expect(&*format!(
"Failed to delete directory {}!",
p.id_as_animals()
));
match fs::remove_dir(format!("./pasta_data/{}/", p.id_as_animals())) {
Ok(_) => {}
Err(_) => {
log::error!("Failed to delete directory {}!", p.file)
}
}
// remove
false
}
});
dbio::save_to_file(pastas);
}
pub fn is_valid_url(url: &str) -> bool {