mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
Fix Rust 1.57 compiler and clippy warnings (#2863)
* Remove unused os_name * Disable clippy::manual_split_once lint It's suggestions in stable 1.57 Rust are incorrect: https://github.com/rust-lang/rust-clippy/issues/7889 * Allow unused fields in OAuth2 response * Fix clippy warning about `select_pk_for_encryption`
This commit is contained in:
@@ -63,7 +63,7 @@ pub type dc_context_t = Context;
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn dc_context_new(
|
pub unsafe extern "C" fn dc_context_new(
|
||||||
os_name: *const libc::c_char,
|
_os_name: *const libc::c_char,
|
||||||
dbfile: *const libc::c_char,
|
dbfile: *const libc::c_char,
|
||||||
blobdir: *const libc::c_char,
|
blobdir: *const libc::c_char,
|
||||||
) -> *mut dc_context_t {
|
) -> *mut dc_context_t {
|
||||||
@@ -74,21 +74,11 @@ pub unsafe extern "C" fn dc_context_new(
|
|||||||
return ptr::null_mut();
|
return ptr::null_mut();
|
||||||
}
|
}
|
||||||
|
|
||||||
let os_name = if os_name.is_null() {
|
|
||||||
String::from("DcFFI")
|
|
||||||
} else {
|
|
||||||
to_string_lossy(os_name)
|
|
||||||
};
|
|
||||||
|
|
||||||
let ctx = if blobdir.is_null() || *blobdir == 0 {
|
let ctx = if blobdir.is_null() || *blobdir == 0 {
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
// generate random ID as this functionality is not yet available on the C-api.
|
// generate random ID as this functionality is not yet available on the C-api.
|
||||||
let id = rand::thread_rng().gen();
|
let id = rand::thread_rng().gen();
|
||||||
block_on(Context::new(
|
block_on(Context::new(as_path(dbfile).to_path_buf().into(), id))
|
||||||
os_name,
|
|
||||||
as_path(dbfile).to_path_buf().into(),
|
|
||||||
id,
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
eprintln!("blobdir can not be defined explicitly anymore");
|
eprintln!("blobdir can not be defined explicitly anymore");
|
||||||
return ptr::null_mut();
|
return ptr::null_mut();
|
||||||
@@ -3839,7 +3829,7 @@ pub type dc_accounts_t = AccountsWrapper;
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn dc_accounts_new(
|
pub unsafe extern "C" fn dc_accounts_new(
|
||||||
os_name: *const libc::c_char,
|
_os_name: *const libc::c_char,
|
||||||
dbfile: *const libc::c_char,
|
dbfile: *const libc::c_char,
|
||||||
) -> *mut dc_accounts_t {
|
) -> *mut dc_accounts_t {
|
||||||
setup_panic!();
|
setup_panic!();
|
||||||
@@ -3849,13 +3839,7 @@ pub unsafe extern "C" fn dc_accounts_new(
|
|||||||
return ptr::null_mut();
|
return ptr::null_mut();
|
||||||
}
|
}
|
||||||
|
|
||||||
let os_name = if os_name.is_null() {
|
let accs = block_on(Accounts::new(as_path(dbfile).to_path_buf().into()));
|
||||||
String::from("DcFFI")
|
|
||||||
} else {
|
|
||||||
to_string_lossy(os_name)
|
|
||||||
};
|
|
||||||
|
|
||||||
let accs = block_on(Accounts::new(os_name, as_path(dbfile).to_path_buf().into()));
|
|
||||||
|
|
||||||
match accs {
|
match accs {
|
||||||
Ok(accs) => Box::into_raw(Box::new(AccountsWrapper::new(accs))),
|
Ok(accs) => Box::into_raw(Box::new(AccountsWrapper::new(accs))),
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ async fn start(args: Vec<String>) -> Result<(), Error> {
|
|||||||
println!("Error: Bad arguments, expected [db-name].");
|
println!("Error: Bad arguments, expected [db-name].");
|
||||||
bail!("No db-name specified");
|
bail!("No db-name specified");
|
||||||
}
|
}
|
||||||
let context = Context::new("CLI".into(), Path::new(&args[1]).to_path_buf(), 0).await?;
|
let context = Context::new(Path::new(&args[1]).to_path_buf(), 0).await?;
|
||||||
|
|
||||||
let events = context.get_event_emitter();
|
let events = context.get_event_emitter();
|
||||||
async_std::task::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ async fn main() {
|
|||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let dbfile = dir.path().join("db.sqlite");
|
let dbfile = dir.path().join("db.sqlite");
|
||||||
log::info!("creating database {:?}", dbfile);
|
log::info!("creating database {:?}", dbfile);
|
||||||
let ctx = Context::new("FakeOs".into(), dbfile.into(), 0)
|
let ctx = Context::new(dbfile.into(), 0)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to create context");
|
.expect("Failed to create context");
|
||||||
let info = ctx.get_info().await;
|
let info = ctx.get_info().await;
|
||||||
|
|||||||
@@ -29,21 +29,21 @@ pub struct Accounts {
|
|||||||
|
|
||||||
impl Accounts {
|
impl Accounts {
|
||||||
/// Loads or creates an accounts folder at the given `dir`.
|
/// Loads or creates an accounts folder at the given `dir`.
|
||||||
pub async fn new(os_name: String, dir: PathBuf) -> Result<Self> {
|
pub async fn new(dir: PathBuf) -> Result<Self> {
|
||||||
if !dir.exists().await {
|
if !dir.exists().await {
|
||||||
Accounts::create(os_name, &dir).await?;
|
Accounts::create(&dir).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accounts::open(dir).await
|
Accounts::open(dir).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new default structure.
|
/// Creates a new default structure.
|
||||||
pub async fn create(os_name: String, dir: &PathBuf) -> Result<()> {
|
pub async fn create(dir: &PathBuf) -> Result<()> {
|
||||||
fs::create_dir_all(dir)
|
fs::create_dir_all(dir)
|
||||||
.await
|
.await
|
||||||
.context("failed to create folder")?;
|
.context("failed to create folder")?;
|
||||||
|
|
||||||
Config::new(os_name.clone(), dir).await?;
|
Config::new(dir).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -106,10 +106,9 @@ impl Accounts {
|
|||||||
|
|
||||||
/// Add a new account.
|
/// Add a new account.
|
||||||
pub async fn add_account(&mut self) -> Result<u32> {
|
pub async fn add_account(&mut self) -> Result<u32> {
|
||||||
let os_name = self.config.os_name().await;
|
|
||||||
let account_config = self.config.new_account(&self.dir).await?;
|
let account_config = self.config.new_account(&self.dir).await?;
|
||||||
|
|
||||||
let ctx = Context::new(os_name, account_config.dbfile().into(), account_config.id).await?;
|
let ctx = Context::new(account_config.dbfile().into(), account_config.id).await?;
|
||||||
self.emitter.add_account(&ctx).await?;
|
self.emitter.add_account(&ctx).await?;
|
||||||
self.accounts.insert(account_config.id, ctx);
|
self.accounts.insert(account_config.id, ctx);
|
||||||
|
|
||||||
@@ -183,13 +182,7 @@ impl Accounts {
|
|||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let ctx = Context::with_blobdir(
|
let ctx = Context::with_blobdir(new_dbfile, new_blobdir, account_config.id).await?;
|
||||||
self.config.os_name().await,
|
|
||||||
new_dbfile,
|
|
||||||
new_blobdir,
|
|
||||||
account_config.id,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
self.emitter.add_account(&ctx).await?;
|
self.emitter.add_account(&ctx).await?;
|
||||||
self.accounts.insert(account_config.id, ctx);
|
self.accounts.insert(account_config.id, ctx);
|
||||||
Ok(account_config.id)
|
Ok(account_config.id)
|
||||||
@@ -349,7 +342,6 @@ pub struct Config {
|
|||||||
/// This is serialized into TOML.
|
/// This is serialized into TOML.
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
struct InnerConfig {
|
struct InnerConfig {
|
||||||
pub os_name: String,
|
|
||||||
/// The currently selected account.
|
/// The currently selected account.
|
||||||
pub selected_account: u32,
|
pub selected_account: u32,
|
||||||
pub next_id: u32,
|
pub next_id: u32,
|
||||||
@@ -357,9 +349,8 @@ struct InnerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub async fn new(os_name: String, dir: &PathBuf) -> Result<Self> {
|
pub async fn new(dir: &PathBuf) -> Result<Self> {
|
||||||
let inner = InnerConfig {
|
let inner = InnerConfig {
|
||||||
os_name,
|
|
||||||
accounts: Vec::new(),
|
accounts: Vec::new(),
|
||||||
selected_account: 0,
|
selected_account: 0,
|
||||||
next_id: 1,
|
next_id: 1,
|
||||||
@@ -374,10 +365,6 @@ impl Config {
|
|||||||
Ok(cfg)
|
Ok(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn os_name(&self) -> String {
|
|
||||||
self.inner.os_name.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sync the inmemory representation to disk.
|
/// Sync the inmemory representation to disk.
|
||||||
async fn sync(&self) -> Result<()> {
|
async fn sync(&self) -> Result<()> {
|
||||||
fs::write(&self.file, toml::to_string_pretty(&self.inner)?)
|
fs::write(&self.file, toml::to_string_pretty(&self.inner)?)
|
||||||
@@ -396,12 +383,7 @@ impl Config {
|
|||||||
pub async fn load_accounts(&self) -> Result<BTreeMap<u32, Context>> {
|
pub async fn load_accounts(&self) -> Result<BTreeMap<u32, Context>> {
|
||||||
let mut accounts = BTreeMap::new();
|
let mut accounts = BTreeMap::new();
|
||||||
for account_config in &self.inner.accounts {
|
for account_config in &self.inner.accounts {
|
||||||
let ctx = Context::new(
|
let ctx = Context::new(account_config.dbfile().into(), account_config.id).await?;
|
||||||
self.inner.os_name.clone(),
|
|
||||||
account_config.dbfile().into(),
|
|
||||||
account_config.id,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
accounts.insert(account_config.id, ctx);
|
accounts.insert(account_config.id, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +480,7 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts1").into();
|
let p: PathBuf = dir.path().join("accounts1").into();
|
||||||
|
|
||||||
let mut accounts1 = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
let mut accounts1 = Accounts::new(p.clone()).await.unwrap();
|
||||||
accounts1.add_account().await.unwrap();
|
accounts1.add_account().await.unwrap();
|
||||||
|
|
||||||
let accounts2 = Accounts::open(p).await.unwrap();
|
let accounts2 = Accounts::open(p).await.unwrap();
|
||||||
@@ -516,7 +498,7 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let mut accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
let mut accounts = Accounts::new(p.clone()).await.unwrap();
|
||||||
assert_eq!(accounts.accounts.len(), 0);
|
assert_eq!(accounts.accounts.len(), 0);
|
||||||
assert_eq!(accounts.config.get_selected_account().await, 0);
|
assert_eq!(accounts.config.get_selected_account().await, 0);
|
||||||
|
|
||||||
@@ -543,7 +525,7 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let mut accounts = Accounts::new("my_os".into(), p.clone()).await?;
|
let mut accounts = Accounts::new(p.clone()).await?;
|
||||||
assert!(accounts.get_selected_account().await.is_none());
|
assert!(accounts.get_selected_account().await.is_none());
|
||||||
assert_eq!(accounts.config.get_selected_account().await, 0);
|
assert_eq!(accounts.config.get_selected_account().await, 0);
|
||||||
|
|
||||||
@@ -564,14 +546,12 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let mut accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
let mut accounts = Accounts::new(p.clone()).await.unwrap();
|
||||||
assert_eq!(accounts.accounts.len(), 0);
|
assert_eq!(accounts.accounts.len(), 0);
|
||||||
assert_eq!(accounts.config.get_selected_account().await, 0);
|
assert_eq!(accounts.config.get_selected_account().await, 0);
|
||||||
|
|
||||||
let extern_dbfile: PathBuf = dir.path().join("other").into();
|
let extern_dbfile: PathBuf = dir.path().join("other").into();
|
||||||
let ctx = Context::new("my_os".into(), extern_dbfile.clone(), 0)
|
let ctx = Context::new(extern_dbfile.clone(), 0).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
ctx.set_config(crate::config::Config::Addr, Some("me@mail.com"))
|
ctx.set_config(crate::config::Config::Addr, Some("me@mail.com"))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -601,7 +581,7 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let mut accounts = Accounts::new("my_os".into(), p.clone()).await.unwrap();
|
let mut accounts = Accounts::new(p.clone()).await.unwrap();
|
||||||
|
|
||||||
for expected_id in 1..10 {
|
for expected_id in 1..10 {
|
||||||
let id = accounts.add_account().await.unwrap();
|
let id = accounts.add_account().await.unwrap();
|
||||||
@@ -621,7 +601,7 @@ mod tests {
|
|||||||
let dummy_accounts = 10;
|
let dummy_accounts = 10;
|
||||||
|
|
||||||
let (id0, id1, id2) = {
|
let (id0, id1, id2) = {
|
||||||
let mut accounts = Accounts::new("my_os".into(), p.clone()).await?;
|
let mut accounts = Accounts::new(p.clone()).await?;
|
||||||
accounts.add_account().await?;
|
accounts.add_account().await?;
|
||||||
let ids = accounts.get_all().await;
|
let ids = accounts.get_all().await;
|
||||||
assert_eq!(ids.len(), 1);
|
assert_eq!(ids.len(), 1);
|
||||||
@@ -656,7 +636,7 @@ mod tests {
|
|||||||
assert!(id2 > id1 + dummy_accounts);
|
assert!(id2 > id1 + dummy_accounts);
|
||||||
|
|
||||||
let (id0_reopened, id1_reopened, id2_reopened) = {
|
let (id0_reopened, id1_reopened, id2_reopened) = {
|
||||||
let accounts = Accounts::new("my_os".into(), p.clone()).await?;
|
let accounts = Accounts::new(p.clone()).await?;
|
||||||
let ctx = accounts.get_selected_account().await.unwrap();
|
let ctx = accounts.get_selected_account().await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ctx.get_config(crate::config::Config::Addr).await?,
|
ctx.get_config(crate::config::Config::Addr).await?,
|
||||||
@@ -701,7 +681,7 @@ mod tests {
|
|||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let p: PathBuf = dir.path().join("accounts").into();
|
let p: PathBuf = dir.path().join("accounts").into();
|
||||||
|
|
||||||
let accounts = Accounts::new("my_os".into(), p.clone()).await?;
|
let accounts = Accounts::new(p.clone()).await?;
|
||||||
|
|
||||||
// Make sure there are no accounts.
|
// Make sure there are no accounts.
|
||||||
assert_eq!(accounts.accounts.len(), 0);
|
assert_eq!(accounts.accounts.len(), 0);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ pub struct InnerContext {
|
|||||||
/// Blob directory path
|
/// Blob directory path
|
||||||
pub(crate) blobdir: PathBuf,
|
pub(crate) blobdir: PathBuf,
|
||||||
pub(crate) sql: Sql,
|
pub(crate) sql: Sql,
|
||||||
pub(crate) os_name: Option<String>,
|
|
||||||
pub(crate) bob: Bob,
|
pub(crate) bob: Bob,
|
||||||
pub(crate) last_smeared_timestamp: RwLock<i64>,
|
pub(crate) last_smeared_timestamp: RwLock<i64>,
|
||||||
pub(crate) running_state: RwLock<RunningState>,
|
pub(crate) running_state: RwLock<RunningState>,
|
||||||
@@ -108,7 +107,7 @@ pub fn get_info() -> BTreeMap<&'static str, String> {
|
|||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
/// Creates new context.
|
/// Creates new context.
|
||||||
pub async fn new(os_name: String, dbfile: PathBuf, id: u32) -> Result<Context> {
|
pub async fn new(dbfile: PathBuf, id: u32) -> Result<Context> {
|
||||||
// pretty_env_logger::try_init_timed().ok();
|
// pretty_env_logger::try_init_timed().ok();
|
||||||
|
|
||||||
let mut blob_fname = OsString::new();
|
let mut blob_fname = OsString::new();
|
||||||
@@ -118,11 +117,10 @@ impl Context {
|
|||||||
if !blobdir.exists().await {
|
if !blobdir.exists().await {
|
||||||
async_std::fs::create_dir_all(&blobdir).await?;
|
async_std::fs::create_dir_all(&blobdir).await?;
|
||||||
}
|
}
|
||||||
Context::with_blobdir(os_name, dbfile, blobdir, id).await
|
Context::with_blobdir(dbfile, blobdir, id).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn with_blobdir(
|
pub(crate) async fn with_blobdir(
|
||||||
os_name: String,
|
|
||||||
dbfile: PathBuf,
|
dbfile: PathBuf,
|
||||||
blobdir: PathBuf,
|
blobdir: PathBuf,
|
||||||
id: u32,
|
id: u32,
|
||||||
@@ -137,7 +135,6 @@ impl Context {
|
|||||||
id,
|
id,
|
||||||
blobdir,
|
blobdir,
|
||||||
dbfile,
|
dbfile,
|
||||||
os_name: Some(os_name),
|
|
||||||
running_state: RwLock::new(Default::default()),
|
running_state: RwLock::new(Default::default()),
|
||||||
sql: Sql::new(),
|
sql: Sql::new(),
|
||||||
bob: Default::default(),
|
bob: Default::default(),
|
||||||
@@ -653,7 +650,7 @@ mod tests {
|
|||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let dbfile = tmp.path().join("db.sqlite");
|
let dbfile = tmp.path().join("db.sqlite");
|
||||||
std::fs::write(&dbfile, b"123").unwrap();
|
std::fs::write(&dbfile, b"123").unwrap();
|
||||||
let res = Context::new("FakeOs".into(), dbfile.into(), 1).await;
|
let res = Context::new(dbfile.into(), 1).await;
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,9 +801,7 @@ mod tests {
|
|||||||
async fn test_blobdir_exists() {
|
async fn test_blobdir_exists() {
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let dbfile = tmp.path().join("db.sqlite");
|
let dbfile = tmp.path().join("db.sqlite");
|
||||||
Context::new("FakeOS".into(), dbfile.into(), 1)
|
Context::new(dbfile.into(), 1).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let blobdir = tmp.path().join("db.sqlite-blobs");
|
let blobdir = tmp.path().join("db.sqlite-blobs");
|
||||||
assert!(blobdir.is_dir());
|
assert!(blobdir.is_dir());
|
||||||
}
|
}
|
||||||
@@ -817,7 +812,7 @@ mod tests {
|
|||||||
let dbfile = tmp.path().join("db.sqlite");
|
let dbfile = tmp.path().join("db.sqlite");
|
||||||
let blobdir = tmp.path().join("db.sqlite-blobs");
|
let blobdir = tmp.path().join("db.sqlite-blobs");
|
||||||
std::fs::write(&blobdir, b"123").unwrap();
|
std::fs::write(&blobdir, b"123").unwrap();
|
||||||
let res = Context::new("FakeOS".into(), dbfile.into(), 1).await;
|
let res = Context::new(dbfile.into(), 1).await;
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,9 +822,7 @@ mod tests {
|
|||||||
let subdir = tmp.path().join("subdir");
|
let subdir = tmp.path().join("subdir");
|
||||||
let dbfile = subdir.join("db.sqlite");
|
let dbfile = subdir.join("db.sqlite");
|
||||||
let dbfile2 = dbfile.clone();
|
let dbfile2 = dbfile.clone();
|
||||||
Context::new("FakeOS".into(), dbfile.into(), 1)
|
Context::new(dbfile.into(), 1).await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert!(subdir.is_dir());
|
assert!(subdir.is_dir());
|
||||||
assert!(dbfile2.is_file());
|
assert!(dbfile2.is_file());
|
||||||
}
|
}
|
||||||
@@ -839,7 +832,7 @@ mod tests {
|
|||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let dbfile = tmp.path().join("db.sqlite");
|
let dbfile = tmp.path().join("db.sqlite");
|
||||||
let blobdir = PathBuf::new();
|
let blobdir = PathBuf::new();
|
||||||
let res = Context::with_blobdir("FakeOS".into(), dbfile.into(), blobdir, 1).await;
|
let res = Context::with_blobdir(dbfile.into(), blobdir, 1).await;
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,7 +841,7 @@ mod tests {
|
|||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let dbfile = tmp.path().join("db.sqlite");
|
let dbfile = tmp.path().join("db.sqlite");
|
||||||
let blobdir = tmp.path().join("blobs");
|
let blobdir = tmp.path().join("blobs");
|
||||||
let res = Context::with_blobdir("FakeOS".into(), dbfile.into(), blobdir.into(), 1).await;
|
let res = Context::with_blobdir(dbfile.into(), blobdir.into(), 1).await;
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
#![allow(
|
#![allow(
|
||||||
clippy::match_bool,
|
clippy::match_bool,
|
||||||
clippy::eval_order_dependence,
|
clippy::eval_order_dependence,
|
||||||
clippy::bool_assert_comparison
|
clippy::bool_assert_comparison,
|
||||||
|
clippy::manual_split_once
|
||||||
)]
|
)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ struct Oauth2 {
|
|||||||
|
|
||||||
/// OAuth 2 Access Token Response
|
/// OAuth 2 Access Token Response
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[allow(dead_code)]
|
||||||
struct Response {
|
struct Response {
|
||||||
// Should always be there according to: <https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/>
|
// Should always be there according to: <https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/>
|
||||||
// but previous code handled its abscense.
|
// but previous code handled its abscense.
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ pub async fn pk_encrypt(
|
|||||||
let pkeys: Vec<SignedPublicKeyOrSubkey> = public_keys_for_encryption
|
let pkeys: Vec<SignedPublicKeyOrSubkey> = public_keys_for_encryption
|
||||||
.keys()
|
.keys()
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|key| select_pk_for_encryption(key))
|
.filter_map(select_pk_for_encryption)
|
||||||
.collect();
|
.collect();
|
||||||
let pkeys_refs: Vec<&SignedPublicKeyOrSubkey> = pkeys.iter().collect();
|
let pkeys_refs: Vec<&SignedPublicKeyOrSubkey> = pkeys.iter().collect();
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ impl TestContext {
|
|||||||
let mut context_names = CONTEXT_NAMES.write().unwrap();
|
let mut context_names = CONTEXT_NAMES.write().unwrap();
|
||||||
context_names.insert(id, name);
|
context_names.insert(id, name);
|
||||||
}
|
}
|
||||||
let ctx = Context::new("FakeOS".into(), dbfile.into(), id)
|
let ctx = Context::new(dbfile.into(), id)
|
||||||
.await
|
.await
|
||||||
.expect("failed to create context");
|
.expect("failed to create context");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user