diff --git a/.github/images/logo.svg b/.github/images/logo.svg new file mode 100644 index 000000000..9357fab88 --- /dev/null +++ b/.github/images/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/core/src/error.rs b/core/src/error.rs index 7bc3cc12d..cb5958327 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -25,7 +25,7 @@ pub enum CoreError { #[error("{0}")] EmailerError(#[from] email::EmailError), #[error("Query error: {0}")] - QueryError(#[from] prisma_client_rust::queries::QueryError), + QueryError(#[from] Box), #[error("Invalid query error: {0}")] InvalidQuery(String), #[error("Invalid usage of query result, failed to load relation: {0}")] @@ -57,3 +57,9 @@ pub enum CoreError { #[error("An unknown error ocurred: {0}")] Unknown(String), } + +impl From for CoreError { + fn from(error: prisma_client_rust::QueryError) -> Self { + Self::QueryError(Box::new(error)) + } +} diff --git a/core/src/job/error.rs b/core/src/job/error.rs index 8fe75b7d2..c71a7d204 100644 --- a/core/src/job/error.rs +++ b/core/src/job/error.rs @@ -15,18 +15,24 @@ pub enum JobError { #[error("A task experienced a critical error while executing: {0}")] TaskFailed(String), #[error("A query error occurred: {0}")] - QueryError(#[from] prisma_client_rust::QueryError), + QueryError(#[from] Box), #[error("A file error occurred: {0}")] FileError(#[from] FileError), #[error("An unknown error occurred: {0}")] Unknown(String), } +impl From for JobError { + fn from(error: prisma_client_rust::QueryError) -> Self { + Self::QueryError(Box::new(error)) + } +} + impl From for JobError { fn from(err: CoreError) -> Self { match err { - CoreError::QueryError(err) => JobError::QueryError(err), - _ => JobError::Unknown(err.to_string()), + CoreError::QueryError(err) => Self::QueryError(err), + _ => Self::Unknown(err.to_string()), } } } @@ -50,7 +56,7 @@ pub enum JobManagerError { #[error("A job was found which was in a deeply invalid state")] JobLostError, #[error("A query error occurred {0}")] - QueryError(#[from] prisma_client_rust::QueryError), + QueryError(#[from] Box), #[error("An unknown error occurred {0}")] Unknown(String), } @@ -58,8 +64,14 @@ pub enum JobManagerError { impl From for JobManagerError { fn from(job_error: JobError) -> Self { match job_error { - JobError::QueryError(e) => JobManagerError::QueryError(e), - _ => JobManagerError::Unknown(job_error.to_string()), + JobError::QueryError(e) => Self::QueryError(e), + _ => Self::Unknown(job_error.to_string()), } } } + +impl From for JobManagerError { + fn from(error: prisma_client_rust::QueryError) -> Self { + Self::QueryError(Box::new(error)) + } +} diff --git a/core/src/opds/v2_0/error.rs b/core/src/opds/v2_0/error.rs index 0f569410e..bc2424d9a 100644 --- a/core/src/opds/v2_0/error.rs +++ b/core/src/opds/v2_0/error.rs @@ -7,7 +7,7 @@ pub enum OPDSV2Error { #[error("OPDS feed field was not initialized: {0}")] MalformedFeed(#[from] UninitializedFieldError), #[error("A query failed while generated OPDS feed: {0}")] - QueryError(#[from] prisma_client_rust::queries::QueryError), + QueryError(#[from] Box), #[error("Failed to generate OPDS feed: {0}")] InternalError(#[from] crate::CoreError), } @@ -25,6 +25,12 @@ impl From for crate::CoreError { } } +impl From for OPDSV2Error { + fn from(error: prisma_client_rust::QueryError) -> Self { + Self::QueryError(Box::new(error)) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/cli/src/error.rs b/crates/cli/src/error.rs index fcb6d3dd7..c80d5e136 100644 --- a/crates/cli/src/error.rs +++ b/crates/cli/src/error.rs @@ -8,7 +8,7 @@ pub enum CliError { #[error("{0}")] OperationFailed(String), #[error("{0}")] - QueryError(#[from] QueryError), + QueryError(#[from] Box), #[error("{0}")] Unknown(String), } @@ -22,4 +22,10 @@ impl From for CliError { } } +impl From for CliError { + fn from(error: prisma_client_rust::QueryError) -> Self { + Self::QueryError(Box::new(error)) + } +} + pub type CliResult = Result; diff --git a/packages/browser/src/components/explorer/FileExplorerProvider.tsx b/packages/browser/src/components/explorer/FileExplorerProvider.tsx index 2959c4fcc..d821a0592 100644 --- a/packages/browser/src/components/explorer/FileExplorerProvider.tsx +++ b/packages/browser/src/components/explorer/FileExplorerProvider.tsx @@ -1,4 +1,4 @@ -import { useDirectoryListing } from '@stump/client' +import { useDirectoryListing, useSDK } from '@stump/client' import { DirectoryListingFile } from '@stump/sdk' import React, { useState } from 'react' import toast from 'react-hot-toast' @@ -22,6 +22,7 @@ type Props = { export default function FileExplorerProvider({ rootPath }: Props) { const navigate = useNavigate() const isMobile = useMediaMatch('(max-width: 768px)') + const { sdk } = useSDK() const [layout, setLayout] = useState(() => getDefaultLayout()) @@ -39,7 +40,7 @@ export default function FileExplorerProvider({ rootPath }: Props) { setPath(entry.path) } else { try { - const entity = await getBook(entry.path) + const entity = await getBook(entry.path, sdk) if (entity) { navigate(paths.bookOverview(entity.id), { state: { diff --git a/packages/browser/src/components/explorer/grid/FileGridItem.tsx b/packages/browser/src/components/explorer/grid/FileGridItem.tsx index 0e277ac8c..42d35ab35 100644 --- a/packages/browser/src/components/explorer/grid/FileGridItem.tsx +++ b/packages/browser/src/components/explorer/grid/FileGridItem.tsx @@ -1,3 +1,4 @@ +import { useSDK } from '@stump/client' import { Text, ToolTip } from '@stump/components' import { DirectoryListingFile, Media } from '@stump/sdk' import React, { useEffect, useMemo, useState } from 'react' @@ -13,6 +14,7 @@ type Props = { export default function FileGridItem({ file }: Props) { const { name, path, is_directory } = file + const { sdk } = useSDK() const { onSelect } = useFileExplorerContext() @@ -27,7 +29,7 @@ export default function FileGridItem({ file }: Props) { useEffect(() => { async function tryGetMedia() { // Note: This should be cached, so it should be fast - const maybeBook = await getBook(path) + const maybeBook = await getBook(path, sdk) if (maybeBook) { setBook(maybeBook) } @@ -36,7 +38,7 @@ export default function FileGridItem({ file }: Props) { if (!is_directory) { tryGetMedia() } - }, [path, is_directory]) + }, [path, is_directory, sdk]) return (