Debug
This commit is contained in:
parent
7df4117c7d
commit
cb67709ba5
|
@ -169,15 +169,11 @@ pub async fn store_file(
|
|||
// Write to file
|
||||
// room_id is guaranteed to be present at this point
|
||||
let room_id = room_id.unwrap();
|
||||
match std::fs::create_dir_all(format!("files/{}", &room_id)) {
|
||||
match std::fs::create_dir_all(format!("files/{}_files", &room_id)) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
error!("Couldn't store file due to error: {}.", e);
|
||||
return Err(warp::reject::custom(Error::DatabaseFailedInternally));
|
||||
}
|
||||
Err(_) => (),
|
||||
};
|
||||
let raw_path = format!("files/{}/{}", &room_id, &id);
|
||||
println!("mmmyess");
|
||||
let raw_path = format!("files/{}_files/{}", &room_id, &id);
|
||||
let path = Path::new(&raw_path);
|
||||
let mut file = match File::create(path).await {
|
||||
Ok(file) => file,
|
||||
|
@ -223,7 +219,7 @@ pub async fn get_file(
|
|||
// Try to read the file
|
||||
let mut bytes = vec![];
|
||||
// room_id is guaranteed to be present at this point
|
||||
let raw_path = format!("files/{}/{}", room_id.unwrap(), id);
|
||||
let raw_path = format!("files/{}_files/{}", room_id.unwrap(), id);
|
||||
let path = Path::new(&raw_path);
|
||||
let mut file = match File::open(path).await {
|
||||
Ok(file) => file,
|
||||
|
|
|
@ -267,7 +267,7 @@ pub async fn prune_files(file_expiration: i64) {
|
|||
// Delete the files
|
||||
let mut deleted_ids: Vec<String> = vec![];
|
||||
for id in ids {
|
||||
match fs::remove_file(format!("files/{}/{}", room, id)) {
|
||||
match fs::remove_file(format!("files/{}_files/{}", room, id)) {
|
||||
Ok(_) => deleted_ids.push(id),
|
||||
Err(e) => error!("Couldn't delete file due to error: {}.", e),
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ async fn test_file_handling() {
|
|||
// Will evaluate to now + 60
|
||||
storage::prune_files(-60).await;
|
||||
// It should be gone now
|
||||
fs::read(format!("files/{}/{}", test_room_id, id)).unwrap_err();
|
||||
fs::read(format!("files/{}_files/{}", test_room_id, id)).unwrap_err();
|
||||
// Check that the file record is also gone
|
||||
let conn = pool.get().unwrap();
|
||||
let raw_query = format!("SELECT id FROM {}", storage::FILES_TABLE);
|
||||
|
|
Loading…
Reference in New Issue