Skip to content

Commit

Permalink
clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
thebino committed Oct 21, 2023
1 parent 3cce3b8 commit a992dc0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions crates/database/src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ impl Database for PostgresDatabase {

sqlx::query(query)
.bind(id.clone())
.bind(&user_id)
.bind(&name)
.bind(user_id)
.bind(name)
.bind(false)
.bind(OffsetDateTime::now_utc())
.bind(date_taken)
Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ impl Database for SqliteDatabase {
let id = Uuid::new_v4().hyphenated().to_string();
let _res: SqliteQueryResult = sqlx::query(query)
.bind(id.clone())
.bind(&media_id)
.bind(&user_id)
.bind(media_id)
.bind(user_id)
.bind(&reference.filepath)
.bind(&reference.filename)
.bind(i64::try_from(reference.size).unwrap())
Expand Down
8 changes: 3 additions & 5 deletions crates/media/src/api/routes/post_media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub(crate) async fn post_media(
"name={}, taken={} => id={}",
name.unwrap(),
date.unwrap(),
uuid.clone().hyphenated().to_string()
uuid.hyphenated().to_string()
);

Ok((
Expand All @@ -97,11 +97,9 @@ pub(crate) async fn post_media(
let location = format!("/media/{}", id);
headers.insert(LOCATION, location.parse().unwrap());

return Err(StatusCode::SEE_OTHER);
}
_ => {
return Err(StatusCode::INTERNAL_SERVER_ERROR);
Err(StatusCode::SEE_OTHER)
}
_ => Err(StatusCode::INTERNAL_SERVER_ERROR),
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions crates/media/src/api/routes/post_media_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ pub(crate) async fn post_media_id(

match result {
Ok(uuid) => {
debug!(
"reference added. uuid={}",
uuid.clone().hyphenated().to_string()
);
debug!("reference added. uuid={}", uuid.hyphenated().to_string());

Ok(uuid.hyphenated().to_string())
}
Expand All @@ -99,11 +96,9 @@ pub(crate) async fn post_media_id(
let location = format!("/media/{}", id);
headers.insert(LOCATION, location.parse().unwrap());

return Err(StatusCode::SEE_OTHER);
}
_ => {
return Err(StatusCode::INTERNAL_SERVER_ERROR);
Err(StatusCode::SEE_OTHER)
}
_ => Err(StatusCode::INTERNAL_SERVER_ERROR),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/media/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl MediaRepositoryTrait for MediaRepository {
return match items_result {
Ok(items) => {
Ok(items
.into_iter()
.iter()
.map(|d| MediaItem {
// TODO: fill in missing info like references, details, tags
// TODO: check references on filesystem
Expand Down Expand Up @@ -133,7 +133,7 @@ impl MediaRepositoryTrait for MediaRepository {
mut tmp_file: File,
) -> Result<Uuid, DataAccessError> {
let path = Path::new("data/files/")
.join(user_id.clone().hyphenated().to_string())
.join(user_id.hyphenated().to_string())
.join(media_id.clone())
.join(name.clone());

Expand Down

0 comments on commit a992dc0

Please sign in to comment.