[F] Check 404
This commit is contained in:
@@ -75,6 +75,7 @@ impl MyApp {
|
|||||||
|
|
||||||
// Reading thumbnail of a file
|
// Reading thumbnail of a file
|
||||||
if params.contains_key("thumb") {
|
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())) {
|
return match self.generator.get_thumb(&PathBuf::from(path.to_owned())) {
|
||||||
Ok(vec) => { vec.resp(200) }
|
Ok(vec) => { vec.resp(200) }
|
||||||
Err(e) => { e.to_string().resp(500) }
|
Err(e) => { e.to_string().resp(500) }
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ impl Thumbnailer {
|
|||||||
pub fn gen(&self, orig: &str, new: &str, pixels: i32) -> Result<()> {
|
pub fn gen(&self, orig: &str, new: &str, pixels: i32) -> Result<()> {
|
||||||
let cmd = self.exec
|
let cmd = self.exec
|
||||||
.replace("%s", &*format!("'{pixels}'"))
|
.replace("%s", &*format!("'{pixels}'"))
|
||||||
.replace("%u", &*format!("'{orig}'"))
|
.replace("%u", &shlex::quote(orig))
|
||||||
.replace("%o", &*format!("'{new}'"));
|
.replace("%o", &shlex::quote(new));
|
||||||
let args: Vec<String> = Shlex::new(&*cmd).collect();
|
let args: Vec<String> = Shlex::new(&*cmd).collect();
|
||||||
let out = Command::new(args[0].to_owned()).args(&args[1..]).output()?;
|
let out = Command::new(args[0].to_owned()).args(&args[1..]).output()?;
|
||||||
if !out.status.success() {
|
if !out.status.success() {
|
||||||
|
|||||||
Reference in New Issue
Block a user