Fix GlobStoreIterator type implementation
... to use new StoreId interface
This commit is contained in:
parent
3f88c27834
commit
aa6f220659
1 changed files with 24 additions and 13 deletions
|
@ -495,7 +495,7 @@ impl Store {
|
||||||
.map_err_into(SEK::GetAllVersionsCallError),
|
.map_err_into(SEK::GetAllVersionsCallError),
|
||||||
Ok(Some(pattern)) => {
|
Ok(Some(pattern)) => {
|
||||||
glob(&pattern[..])
|
glob(&pattern[..])
|
||||||
.map(|paths| GlobStoreIdIterator::new(paths).into())
|
.map(|paths| GlobStoreIdIterator::new(paths, self.path().clone()).into())
|
||||||
.map_err_into(SEK::GlobError)
|
.map_err_into(SEK::GlobError)
|
||||||
.map_err_into(SEK::GetAllVersionsCallError)
|
.map_err_into(SEK::GetAllVersionsCallError)
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ impl Store {
|
||||||
debug!("glob()ing with '{}'", path);
|
debug!("glob()ing with '{}'", path);
|
||||||
glob(&path[..]).map_err_into(SEK::GlobError)
|
glob(&path[..]).map_err_into(SEK::GlobError)
|
||||||
})
|
})
|
||||||
.map(|paths| GlobStoreIdIterator::new(paths).into())
|
.map(|paths| GlobStoreIdIterator::new(paths, self.path().clone()).into())
|
||||||
.map_err_into(SEK::GlobError)
|
.map_err_into(SEK::GlobError)
|
||||||
.map_err_into(SEK::RetrieveForModuleCallError)
|
.map_err_into(SEK::RetrieveForModuleCallError)
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ impl Drop for Store {
|
||||||
* TODO: Unlock them
|
* TODO: Unlock them
|
||||||
*/
|
*/
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let store_id = StoreId::from(self.location.clone());
|
let store_id = StoreId::new(Some(self.location.clone()), PathBuf::from("."));
|
||||||
if let Err(e) = self.execute_hooks_for_id(self.store_unload_aspects.clone(), &store_id) {
|
if let Err(e) = self.execute_hooks_for_id(self.store_unload_aspects.clone(), &store_id) {
|
||||||
debug!("Store-load hooks execution failed. Cannot create store object.");
|
debug!("Store-load hooks execution failed. Cannot create store object.");
|
||||||
warn!("Store Unload Hook error: {:?}", e);
|
warn!("Store Unload Hook error: {:?}", e);
|
||||||
|
@ -1495,11 +1495,13 @@ impl Entry {
|
||||||
mod glob_store_iter {
|
mod glob_store_iter {
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::fmt::Error as FmtError;
|
use std::fmt::Error as FmtError;
|
||||||
|
use std::path::PathBuf;
|
||||||
use glob::Paths;
|
use glob::Paths;
|
||||||
use storeid::StoreId;
|
use storeid::StoreId;
|
||||||
use storeid::StoreIdIterator;
|
use storeid::StoreIdIterator;
|
||||||
|
|
||||||
pub struct GlobStoreIdIterator {
|
pub struct GlobStoreIdIterator {
|
||||||
|
store_path: PathBuf,
|
||||||
paths: Paths,
|
paths: Paths,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1521,8 +1523,9 @@ mod glob_store_iter {
|
||||||
|
|
||||||
impl GlobStoreIdIterator {
|
impl GlobStoreIdIterator {
|
||||||
|
|
||||||
pub fn new(paths: Paths) -> GlobStoreIdIterator {
|
pub fn new(paths: Paths, store_path: PathBuf) -> GlobStoreIdIterator {
|
||||||
GlobStoreIdIterator {
|
GlobStoreIdIterator {
|
||||||
|
store_path: store_path,
|
||||||
paths: paths,
|
paths: paths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1533,15 +1536,23 @@ mod glob_store_iter {
|
||||||
type Item = StoreId;
|
type Item = StoreId;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<StoreId> {
|
fn next(&mut self) -> Option<StoreId> {
|
||||||
self.paths.next().and_then(|o| {
|
self.paths
|
||||||
match o {
|
.next()
|
||||||
Ok(o) => Some(o),
|
.and_then(|o| {
|
||||||
Err(e) => {
|
match o {
|
||||||
debug!("GlobStoreIdIterator error: {:?}", e);
|
Ok(o) => Some(o),
|
||||||
None
|
Err(e) => {
|
||||||
},
|
debug!("GlobStoreIdIterator error: {:?}", e);
|
||||||
}
|
None
|
||||||
}).map(|p| StoreId::from(p))
|
},
|
||||||
|
}
|
||||||
|
}).and_then(|p| {
|
||||||
|
p.strip_prefix(&self.store_path)
|
||||||
|
.ok()
|
||||||
|
.map(|p| {
|
||||||
|
StoreId::new(Some(self.store_path.clone()), PathBuf::from(p))
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue