Compare commits
No commits in common. "ea15e25fe2e59f06ff4523362cb4a9e152ef0267" and "aae05764f5a8aad4790ebd9776face1b00f74589" have entirely different histories.
ea15e25fe2
...
aae05764f5
|
@ -102,32 +102,30 @@ impl FileManager {
|
|||
|
||||
pub fn save(self: &Self, file: &File, kind: LookupKind) -> Result<(), Box<dyn Error>> {
|
||||
let file = file.clone();
|
||||
let midfix = match kind {
|
||||
LookupKind::ByName => "-name-",
|
||||
LookupKind::ByHash => "-hash-"
|
||||
};
|
||||
|
||||
match kind {
|
||||
LookupKind::ByName => {
|
||||
if let Some(name) = file.name.clone() {
|
||||
log::debug!("Using {} as a custom file name", name);
|
||||
return Ok(self.save_int(
|
||||
&file,
|
||||
format!(
|
||||
"{}-name-{}",
|
||||
self.env.redis.prefix,
|
||||
name
|
||||
)
|
||||
)?)
|
||||
} else {
|
||||
if (&file).name.is_none() {
|
||||
return Err("Filename can't be None when LookupKind is ByName!".into())
|
||||
}
|
||||
}
|
||||
_ => log::debug!("No custom file name detected")
|
||||
_ => ()
|
||||
}
|
||||
|
||||
self.save_int(
|
||||
&file,
|
||||
format!(
|
||||
"{}-hash-{}",
|
||||
"{}{}{}",
|
||||
self.env.redis.prefix,
|
||||
file.hash()
|
||||
midfix,
|
||||
match kind {
|
||||
LookupKind::ByName => (&file).name.as_ref().unwrap().clone(),
|
||||
LookupKind::ByHash => (&file).hash()
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ impl UploadFormData {
|
|||
if val.is_checked() {
|
||||
let name = data.get("filename")?;
|
||||
out.filename = Some(name.as_atr_or_none()?);
|
||||
out.lookup_kind = LookupKind::ByName
|
||||
out.lookup_kind = LookupKind::ByHash
|
||||
}
|
||||
},
|
||||
None => ()
|
||||
|
@ -107,6 +107,7 @@ impl UploadFormData {
|
|||
if val.is_checked() {
|
||||
let pass = data.get("password")?;
|
||||
out.password = Some(pass.as_atr_or_none()?);
|
||||
out.lookup_kind = LookupKind::ByName
|
||||
}
|
||||
},
|
||||
None => ()
|
||||
|
|
Loading…
Reference in New Issue