-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
105 additions
and
149 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,47 @@ | ||
mod common; | ||
pub mod entry; | ||
mod filesystem; | ||
pub mod local; | ||
pub mod path; | ||
pub mod s3; | ||
|
||
use std::borrow::Cow; | ||
|
||
use color_eyre::eyre::OptionExt; | ||
pub use common::{Impl, Trait}; | ||
pub use entry::Entry; | ||
pub use filesystem::Filesystem; | ||
use nghe_api::common::filesystem; | ||
|
||
use crate::{config, Error}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct Filesystem { | ||
local: local::Filesystem, | ||
s3: Option<s3::Filesystem>, | ||
} | ||
|
||
impl Filesystem { | ||
pub async fn new(tls: &config::filesystem::Tls, s3: &config::filesystem::S3) -> Self { | ||
let local = local::Filesystem; | ||
let s3 = if s3.enable { Some(s3::Filesystem::new(tls, s3).await) } else { None }; | ||
Self { local, s3 } | ||
} | ||
|
||
pub fn to_impl(&self, filesystem_type: filesystem::Type) -> Result<Impl<'_>, Error> { | ||
Ok(match filesystem_type { | ||
filesystem::Type::Local => Impl::Local(Cow::Borrowed(&self.local)), | ||
filesystem::Type::S3 => Impl::S3(Cow::Borrowed( | ||
self.s3.as_ref().ok_or_eyre("S3 filesystem is not enabled")?, | ||
)), | ||
}) | ||
} | ||
|
||
#[cfg(test)] | ||
pub fn local(&self) -> local::Filesystem { | ||
self.local | ||
} | ||
|
||
#[cfg(test)] | ||
pub fn s3(&self) -> s3::Filesystem { | ||
self.s3.as_ref().unwrap().clone() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
nghe-backend/src/app/route/permission/mod.rs → nghe-backend/src/route/permission/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
pub mod add; | ||
|
||
#[cfg(test)] | ||
pub mod test; | ||
|
||
nghe_proc_macro::build_router! { | ||
modules = [add] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
use nghe_api::common::filesystem; | ||
use typed_path::Utf8TypedPathBuf; | ||
|
||
use crate::filesystem::path; | ||
|
Oops, something went wrong.