in core/src/services/koofr/backend.rs [143:225]
fn build(self) -> Result<impl Access> {
debug!("backend build started: {:?}", &self);
let root = normalize_root(&self.config.root.clone().unwrap_or_default());
debug!("backend use root {}", &root);
if self.config.endpoint.is_empty() {
return Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
.with_operation("Builder::build")
.with_context("service", Scheme::Koofr));
}
debug!("backend use endpoint {}", &self.config.endpoint);
if self.config.email.is_empty() {
return Err(Error::new(ErrorKind::ConfigInvalid, "email is empty")
.with_operation("Builder::build")
.with_context("service", Scheme::Koofr));
}
debug!("backend use email {}", &self.config.email);
let password = match &self.config.password {
Some(password) => Ok(password.clone()),
None => Err(Error::new(ErrorKind::ConfigInvalid, "password is empty")
.with_operation("Builder::build")
.with_context("service", Scheme::Koofr)),
}?;
let signer = Arc::new(Mutex::new(KoofrSigner::default()));
Ok(KoofrBackend {
core: Arc::new(KoofrCore {
info: {
let am = AccessorInfo::default();
am.set_scheme(Scheme::Koofr)
.set_root(&root)
.set_native_capability(Capability {
stat: true,
stat_has_content_length: true,
stat_has_content_type: true,
stat_has_last_modified: true,
create_dir: true,
read: true,
write: true,
write_can_empty: true,
delete: true,
rename: true,
copy: true,
list: true,
list_has_content_length: true,
list_has_content_type: true,
list_has_last_modified: true,
shared: true,
..Default::default()
});
// allow deprecated api here for compatibility
#[allow(deprecated)]
if let Some(client) = self.http_client {
am.update_http_client(|_| client);
}
am.into()
},
root,
endpoint: self.config.endpoint.clone(),
email: self.config.email.clone(),
password,
mount_id: OnceCell::new(),
signer,
}),
})
}