diff --git a/file-store/src/lib.rs b/file-store/src/lib.rs index 566df84b2..58067962a 100644 --- a/file-store/src/lib.rs +++ b/file-store/src/lib.rs @@ -1,4 +1,4 @@ -use std::fs::File; +use std::fs::File as StdFile; use std::ops::{Deref, DerefMut}; use std::path::{Path, PathBuf}; @@ -17,7 +17,7 @@ pub enum Error { pub type Result = std::result::Result; -impl Deref for UpdateFile { +impl Deref for File { type Target = NamedTempFile; fn deref(&self) -> &Self::Target { @@ -25,7 +25,7 @@ impl Deref for UpdateFile { } } -impl DerefMut for UpdateFile { +impl DerefMut for File { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.file } @@ -33,33 +33,33 @@ impl DerefMut for UpdateFile { // #[cfg_attr(test, faux::create)] #[derive(Clone, Debug)] -pub struct UpdateFileStore { +pub struct FileStore { path: PathBuf, } // #[cfg_attr(test, faux::methods)] -impl UpdateFileStore { - pub fn new(path: impl AsRef) -> Result { +impl FileStore { + pub fn new(path: impl AsRef) -> Result { let path = path.as_ref().join(UPDATE_FILES_PATH); std::fs::create_dir_all(&path)?; - Ok(UpdateFileStore { path }) + Ok(FileStore { path }) } /// Creates a new temporary update file. /// A call to `persist` is needed to persist the file in the database. - pub fn new_update(&self) -> Result<(Uuid, UpdateFile)> { + pub fn new_update(&self) -> Result<(Uuid, File)> { let file = NamedTempFile::new_in(&self.path)?; let uuid = Uuid::new_v4(); let path = self.path.join(uuid.to_string()); - let update_file = UpdateFile { file, path }; + let update_file = File { file, path }; Ok((uuid, update_file)) } /// Returns the file corresponding to the requested uuid. - pub fn get_update(&self, uuid: Uuid) -> Result { + pub fn get_update(&self, uuid: Uuid) -> Result { let path = self.path.join(uuid.to_string()); - let file = File::open(path)?; + let file = StdFile::open(path)?; Ok(file) } @@ -84,12 +84,12 @@ impl UpdateFileStore { } } -pub struct UpdateFile { +pub struct File { path: PathBuf, file: NamedTempFile, } -impl UpdateFile { +impl File { pub fn persist(self) -> Result<()> { self.file.persist(&self.path)?; Ok(()) diff --git a/index-scheduler/src/index/updates.rs b/index-scheduler/src/index/updates.rs index 4683b570a..1c8858c31 100644 --- a/index-scheduler/src/index/updates.rs +++ b/index-scheduler/src/index/updates.rs @@ -13,7 +13,7 @@ use uuid::Uuid; use super::error::{IndexError, Result}; use super::index::{Index, IndexMeta}; -use file_store::UpdateFileStore; +use file_store::FileStore; fn serialize_with_wildcard( field: &Setting>, @@ -297,7 +297,7 @@ impl Index { &self, method: IndexDocumentsMethod, primary_key: Option, - file_store: UpdateFileStore, + file_store: FileStore, contents: impl IntoIterator, ) -> Result>> { trace!("performing document addition"); diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index f76655b0f..d6c4d27b6 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -8,7 +8,7 @@ mod utils; use batch::Batch; pub use error::Error; -use file_store::UpdateFileStore; +use file_store::FileStore; use index::Index; pub use task::Task; use task::{Kind, KindWithContent, Status}; @@ -57,7 +57,7 @@ pub struct IndexScheduler { /// The list of tasks currently processing. processing_tasks: Arc>, - file_store: UpdateFileStore, + file_store: FileStore, /// The LMDB environment which the DBs are associated with. env: Env,