[F] Check 404

This commit is contained in:
Azalea Gui
2023-02-23 16:15:05 -05:00
parent ce0f4e8404
commit 6a216552d7
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -75,6 +75,7 @@ impl MyApp {
// Reading thumbnail of a file
if params.contains_key("thumb") {
if !path.is_file() { return "Error: File not found".to_string().resp(404) }
return match self.generator.get_thumb(&PathBuf::from(path.to_owned())) {
Ok(vec) => { vec.resp(200) }
Err(e) => { e.to_string().resp(500) }
+2 -2
View File
@@ -47,8 +47,8 @@ impl Thumbnailer {
pub fn gen(&self, orig: &str, new: &str, pixels: i32) -> Result<()> {
let cmd = self.exec
.replace("%s", &*format!("'{pixels}'"))
.replace("%u", &*format!("'{orig}'"))
.replace("%o", &*format!("'{new}'"));
.replace("%u", &shlex::quote(orig))
.replace("%o", &shlex::quote(new));
let args: Vec<String> = Shlex::new(&*cmd).collect();
let out = Command::new(args[0].to_owned()).args(&args[1..]).output()?;
if !out.status.success() {