Skip to content

Commit

Permalink
Implement per-user settings also for GCS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdejager committed Jul 16, 2021
1 parent d7b931b commit 4261ee4
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ fn make_json_auth(m: &clap::ArgMatches) -> Result<LookupAuthenticator, String> {
}
}

type VfsProducer =
Box<dyn (Fn() -> storage::RooterVfs<storage::RestrictingVfs, auth::User, storage::SbeMeta>) + Send + Sync>;

// Creates the filesystem storage back-end
fn fs_storage_backend(
log: &Logger,
m: &clap::ArgMatches,
) -> Box<dyn (Fn() -> storage::RooterVfs<storage::RestrictingVfs, auth::User, storage::SbeMeta>) + Send + Sync> {
fn fs_storage_backend(log: &Logger, m: &clap::ArgMatches) -> VfsProducer {
let p: PathBuf = m.value_of(args::ROOT_DIR).unwrap().into();
let sub_log = Arc::new(log.new(o!("module" => "storage")));
Box::new(move || {
Expand All @@ -162,10 +162,7 @@ fn fs_storage_backend(
}

// Creates the GCS storage back-end
fn gcs_storage_backend(
log: &Logger,
m: &clap::ArgMatches,
) -> Result<Box<dyn (Fn() -> storage::ChoosingVfs) + Send + Sync>, String> {
fn gcs_storage_backend(log: &Logger, m: &clap::ArgMatches) -> Result<VfsProducer, String> {
let bucket: String = m
.value_of(args::GCS_BUCKET)
.ok_or_else(|| format!("--{} is required when using storage type gcs", args::GCS_BUCKET))?
Expand Down Expand Up @@ -199,14 +196,18 @@ fn gcs_storage_backend(
slog::info!(log, "GCS back-end auth method: {}", auth_method);

let sub_log = Arc::new(log.new(o!("module" => "storage")));
Ok(Box::new(move || storage::ChoosingVfs {
inner: storage::InnerVfs::Cloud(unftp_sbe_gcs::CloudStorage::with_api_base(
base_url.clone(),
bucket.clone(),
root_dir.clone(),
auth_method.clone(),
)),
log: sub_log.clone(),
Ok(Box::new(move || {
storage::RooterVfs::new(storage::RestrictingVfs {
delegate: storage::ChoosingVfs {
inner: storage::InnerVfs::Cloud(unftp_sbe_gcs::CloudStorage::with_api_base(
base_url.clone(),
bucket.clone(),
root_dir.clone(),
auth_method.clone(),
)),
log: sub_log.clone(),
},
})
}))
}

Expand Down

0 comments on commit 4261ee4

Please sign in to comment.