Fix for passing Arc<_> to store interface instead of Box<_>
This commit is contained in:
parent
42e2f18fb3
commit
2f0a557068
9 changed files with 23 additions and 12 deletions
|
@ -22,6 +22,7 @@ use std::process::Command;
|
|||
use std::env;
|
||||
use std::process::exit;
|
||||
use std::io::Stdin;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use clap::App;
|
||||
use clap::AppSettings;
|
||||
|
@ -132,7 +133,7 @@ impl<'a> Runtime<'a> {
|
|||
let store_result = if cli_app.use_inmemory_fs() {
|
||||
Store::new_with_backend(storepath,
|
||||
&config,
|
||||
Box::new(InMemoryFileAbstraction::default()))
|
||||
Arc::new(InMemoryFileAbstraction::default()))
|
||||
} else {
|
||||
Store::new(storepath, &config)
|
||||
};
|
||||
|
|
|
@ -1202,12 +1202,13 @@ Hai
|
|||
#[cfg(test)]
|
||||
mod store_tests {
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::Store;
|
||||
use file_abstraction::InMemoryFileAbstraction;
|
||||
|
||||
pub fn get_store() -> Store {
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
@ -1390,10 +1391,11 @@ mod store_tests {
|
|||
#[test]
|
||||
fn test_swap_backend_during_runtime() {
|
||||
use file_abstraction::InMemoryFileAbstraction;
|
||||
use std::sync::Arc;
|
||||
|
||||
let mut store = {
|
||||
let backend = InMemoryFileAbstraction::default();
|
||||
let backend = Box::new(backend);
|
||||
let backend = Arc::new(backend);
|
||||
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
};
|
||||
|
@ -1409,7 +1411,7 @@ mod store_tests {
|
|||
|
||||
{
|
||||
let other_backend = InMemoryFileAbstraction::default();
|
||||
let other_backend = Box::new(other_backend);
|
||||
let other_backend = Arc::new(other_backend);
|
||||
|
||||
assert!(store.reset_backend(other_backend).is_ok())
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ pub mod tag;
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::sync::Arc;
|
||||
|
||||
use chrono::naive::NaiveDate;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
|
@ -37,7 +39,7 @@ mod test {
|
|||
use std::path::PathBuf;
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ impl CategoryStore for Store {
|
|||
mod tests {
|
||||
extern crate env_logger;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -118,7 +119,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::store::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ fn val_to_ndt(v: &Value) -> Result<NaiveDateTime> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -204,10 +204,11 @@ mod tests {
|
|||
use chrono::naive::NaiveDateTime;
|
||||
use chrono::naive::NaiveDate;
|
||||
use chrono::naive::NaiveTime;
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::store::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ impl GPSEntry for Entry {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
|
||||
|
@ -113,7 +114,7 @@ mod tests {
|
|||
|
||||
fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -406,6 +406,7 @@ impl ExternalLinker for Entry {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
|
||||
|
@ -416,7 +417,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -772,6 +772,7 @@ pub mod store_check {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
|
||||
|
@ -784,7 +785,7 @@ mod test {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
let backend = Arc::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
use libimagentrylink::internal::InternalLinker;
|
||||
|
@ -244,7 +245,7 @@ mod tests {
|
|||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let fs = InMemoryFileAbstraction::default();
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, Box::new(fs)).unwrap()
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, Arc::new(fs)).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue