fix hardcoded link
This commit is contained in:
parent
92b8ebffb3
commit
ff66e120b9
|
@ -33,6 +33,7 @@ impl FileManager {
|
||||||
Ok(Some(serde_json::from_str(data.as_str())?))
|
Ok(Some(serde_json::from_str(data.as_str())?))
|
||||||
}
|
}
|
||||||
pub fn find_by_name(self: &Self, name: String) -> Result<Option<File>, Box<dyn Error>> {
|
pub fn find_by_name(self: &Self, name: String) -> Result<Option<File>, Box<dyn Error>> {
|
||||||
|
println!("{}-name-{}", self.env.redis.prefix, name);
|
||||||
Ok(self.find(format!("{}-name-{}", self.env.redis.prefix, name))?)
|
Ok(self.find(format!("{}-name-{}", self.env.redis.prefix, name))?)
|
||||||
}
|
}
|
||||||
pub fn find_by_hash(self: &Self, hash: String) -> Result<Option<File>, Box<dyn Error>> {
|
pub fn find_by_hash(self: &Self, hash: String) -> Result<Option<File>, Box<dyn Error>> {
|
||||||
|
|
|
@ -29,6 +29,13 @@ impl File {
|
||||||
pub fn hash(self: &Self) -> String {
|
pub fn hash(self: &Self) -> String {
|
||||||
self.sha512.clone()
|
self.sha512.clone()
|
||||||
}
|
}
|
||||||
|
pub fn leftmost_link(self: &Self) -> String {
|
||||||
|
if self.name.is_none() {
|
||||||
|
self.hash()
|
||||||
|
} else {
|
||||||
|
self.name.clone().unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn read(self: &Self) -> Result<Vec<u8>, Box<dyn Error>> {
|
pub async fn read(self: &Self) -> Result<Vec<u8>, Box<dyn Error>> {
|
||||||
let data = self.read_unchecked().await?;
|
let data = self.read_unchecked().await?;
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub async fn upload(form: FormData, state: SharedState) -> Result<Box<dyn Reply>
|
||||||
|
|
||||||
let uploaded = UploadSuccessPage {
|
let uploaded = UploadSuccessPage {
|
||||||
env: state.env.clone(),
|
env: state.env.clone(),
|
||||||
link: "uwu".into()
|
link: file.leftmost_link()
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Box::new(warp::reply::html(uploaded.render().unwrap())))
|
Ok(Box::new(warp::reply::html(uploaded.render().unwrap())))
|
||||||
|
|
Loading…
Reference in New Issue