Skip to content

Commit

Permalink
Address warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Sep 20, 2024
1 parent e1e3b75 commit 08161de
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
30 changes: 18 additions & 12 deletions deepwell/src/endpoints/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
use super::prelude::*;
use crate::models::file::Model as FileModel;
use crate::models::file_revision::Model as FileRevisionModel;
use crate::services::blob::BlobService;
use crate::services::blob::{BlobMetadata, BlobService, GetBlobOutput};
use crate::services::file::{
DeleteFile, DeleteFileOutput, EditFile, EditFileOutput, FinishFileCreation,
FinishFileCreationOutput, GetBlobOutput, GetFileDetails, GetFileOutput, MoveFile,
MoveFileOutput, RestoreFile, RestoreFileOutput, StartFileCreation,
StartFileCreationOutput,
FinishFileCreationOutput, GetFileDetails, GetFileOutput, MoveFile, MoveFileOutput,
RestoreFile, RestoreFileOutput, StartFileCreation, StartFileCreationOutput,
};
use crate::services::Result;
use crate::web::{Bytes, FileDetails};
Expand All @@ -41,14 +40,19 @@ pub async fn blob_get(
info!("Getting blob for S3 hash");
let hash: Bytes = params.parse()?;
let data = BlobService::get(ctx, hash.as_ref()).await?;
let metadata = BlobService::get_metadata(ctx, hash.as_ref()).await?;

let output = GetBlobOutput {
let BlobMetadata {
mime,
size,
created_at,
} = BlobService::get_metadata(ctx, hash.as_ref()).await?;

Ok(GetBlobOutput {
data,
mime: metadata.mime,
size: metadata.size,
};
Ok(output)
mime,
size,
created_at,
})
}

pub async fn file_get(
Expand Down Expand Up @@ -114,16 +118,18 @@ pub async fn file_create_finish(
// TODO
pub async fn file_edit_start(
ctx: &ServiceContext<'_>,
params: Params<'static>,
_params: Params<'static>,
) -> Result<()> {
let _ = FileService::start_edit_upload(ctx).await?;
todo!()
}

// TODO
pub async fn file_edit_finish(
ctx: &ServiceContext<'_>,
params: Params<'static>,
_params: Params<'static>,
) -> Result<()> {
let _ = FileService::finish_edit_upload(ctx).await?;
todo!()
}

Expand Down
8 changes: 8 additions & 0 deletions deepwell/src/services/blob/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ pub struct BlobMetadata {
pub size: i64,
pub created_at: OffsetDateTime,
}

#[derive(Serialize, Debug, Clone)]
pub struct GetBlobOutput {
pub data: Vec<u8>,
pub mime: String,
pub size: i64,
pub created_at: OffsetDateTime,
}
6 changes: 2 additions & 4 deletions deepwell/src/services/file/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,12 @@ impl FileService {

/// Edits a file by uploading a new file version.
/// TODO needs to be implemented
pub async fn start_edit_upload(
ctx: &ServiceContext<'_>,
) -> Result<()> {
pub async fn start_edit_upload(_ctx: &ServiceContext<'_>) -> Result<i16> {
todo!()
}

// TODO
pub async fn finish_edit_upload(ctx: &ServiceContext<'_>) -> Result<()> {
pub async fn finish_edit_upload(_ctx: &ServiceContext<'_>) -> Result<i16> {
todo!()
}

Expand Down
7 changes: 0 additions & 7 deletions deepwell/src/services/file/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ pub struct GetFileOutput {
pub hidden_fields: Vec<String>,
}

#[derive(Serialize, Debug, Clone)]
pub struct GetBlobOutput {
pub data: Vec<u8>,
pub mime: String,
pub size: i64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct EditFile {
pub site_id: i64,
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/services/import/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl ImportService {
let output = BlobService::create(ctx, &bytes).await?;
Some(output.hash.to_vec())
*/
let _ = bytes;
todo!()
}
};
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/services/user/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ impl UserService {
Some(hash.to_vec())
*/
let _ = blob;
todo!()
}
};
Expand Down

0 comments on commit 08161de

Please sign in to comment.