Added error checking for file creation in create metadata endpoint
This commit is contained in:
+9
-1
@@ -784,7 +784,9 @@ pub mod endpoint {
|
|||||||
let dir = std::path::Path::new(&song.directory);
|
let dir = std::path::Path::new(&song.directory);
|
||||||
let save_path = dir.join(&song.filename);
|
let save_path = dir.join(&song.filename);
|
||||||
|
|
||||||
let mut file = std::fs::File::create(&save_path).unwrap();
|
// let mut file = std::fs::File::create(&save_path).unwrap();
|
||||||
|
match std::fs::File::create(&save_path) {
|
||||||
|
Ok(mut file) => {
|
||||||
file.write_all(&song.data).unwrap();
|
file.write_all(&song.data).unwrap();
|
||||||
|
|
||||||
match song.song_path() {
|
match song.song_path() {
|
||||||
@@ -807,6 +809,12 @@ pub mod endpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
response.message = err.to_string();
|
||||||
|
(axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
|
|||||||
Reference in New Issue
Block a user