Implement all the todos

This commit is contained in:
asonix 2023-09-03 17:11:34 -05:00
parent 94cb2a9ef3
commit a2933dbebc
6 changed files with 25 additions and 12 deletions

View file

@ -166,7 +166,7 @@ impl UploadError {
Self::InvalidToken => ErrorCode::INVALID_DELETE_TOKEN,
Self::UnsupportedProcessExtension => ErrorCode::INVALID_FILE_EXTENSION,
Self::DuplicateAlias => ErrorCode::DUPLICATE_ALIAS,
Self::PushJob(_) => todo!(),
Self::PushJob(_) => ErrorCode::PUSH_JOB,
Self::Range => ErrorCode::RANGE_NOT_SATISFIABLE,
Self::Limit(_) => ErrorCode::VALIDATE_FILE_SIZE,
Self::Timeout(_) => ErrorCode::STREAM_TOO_SLOW,

View file

@ -56,12 +56,16 @@ impl ErrorCode {
code: "already-claimed",
};
pub(crate) const SLED_ERROR: ErrorCode = ErrorCode { code: "sled-error" };
pub(crate) const POSTGRES_ERROR: ErrorCode = ErrorCode {
code: "postgres-error",
};
pub(crate) const EXTRACT_DETAILS: ErrorCode = ErrorCode {
code: "extract-details",
};
pub(crate) const EXTRACT_UPLOAD_RESULT: ErrorCode = ErrorCode {
code: "extract-upload-result",
};
pub(crate) const PUSH_JOB: ErrorCode = ErrorCode { code: "push-job" };
pub(crate) const EXTRACT_JOB: ErrorCode = ErrorCode {
code: "extract-job",
};

View file

@ -2038,16 +2038,14 @@ impl PictRsConfiguration {
match repo {
Repo::Sled(sled_repo) => {
launch_file_store(
Arc::new(sled_repo.clone()),
store,
client,
config,
move |sc| sled_extra_config(sc, sled_repo.clone()),
)
launch_file_store(arc_repo, store, client, config, move |sc| {
sled_extra_config(sc, sled_repo.clone())
})
.await?;
}
Repo::Postgres(_) => todo!(),
Repo::Postgres(_) => {
launch_file_store(arc_repo, store, client, config, |_| {}).await?;
}
}
}
config::Store::ObjectStorage(config::ObjectStorage {
@ -2101,7 +2099,9 @@ impl PictRsConfiguration {
})
.await?;
}
Repo::Postgres(_) => todo!(),
Repo::Postgres(_) => {
launch_object_store(arc_repo, store, client, config, |_| {}).await?;
}
}
}
}

View file

@ -877,7 +877,7 @@ impl Repo {
pub(crate) fn to_arc(&self) -> ArcRepo {
match self {
Self::Sled(sled_repo) => Arc::new(sled_repo.clone()),
Self::Postgres(_) => todo!(),
Self::Postgres(postgres_repo) => Arc::new(postgres_repo.clone()),
}
}
}

View file

@ -120,7 +120,15 @@ pub(crate) enum PostgresError {
impl PostgresError {
pub(super) const fn error_code(&self) -> ErrorCode {
todo!()
match self {
Self::Pool(_)
| Self::Diesel(_)
| Self::SerializeDetails(_)
| Self::SerializeUploadResult(_)
| Self::Hex(_) => ErrorCode::POSTGRES_ERROR,
Self::DeserializeDetails(_) => ErrorCode::EXTRACT_DETAILS,
Self::DeserializeUploadResult(_) => ErrorCode::EXTRACT_UPLOAD_RESULT,
}
}
}

View file

@ -83,6 +83,7 @@ diesel::table! {
uploads (id) {
id -> Uuid,
result -> Nullable<Jsonb>,
created_at -> Timestamp,
}
}