commit
e93cf199ec
8 changed files with 113 additions and 15 deletions
|
@ -38,6 +38,9 @@ version = ">=2.29"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["color", "suggestions"]
|
features = ["color", "suggestions"]
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
env_logger = "0.5"
|
||||||
|
|
||||||
[dev-dependencies.libimagutil]
|
[dev-dependencies.libimagutil]
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
path = "../../../lib/etc/libimagutil"
|
path = "../../../lib/etc/libimagutil"
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern crate clap;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
#[cfg(test)] extern crate toml;
|
#[cfg(test)] extern crate toml;
|
||||||
#[cfg(test)] extern crate toml_query;
|
#[cfg(test)] extern crate toml_query;
|
||||||
|
#[cfg(test)] extern crate env_logger;
|
||||||
|
|
||||||
extern crate libimagentrylink;
|
extern crate libimagentrylink;
|
||||||
#[macro_use] extern crate libimagrt;
|
#[macro_use] extern crate libimagrt;
|
||||||
|
@ -119,8 +120,12 @@ fn main() {
|
||||||
fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockEntry<'a>>, StoreError> {
|
fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockEntry<'a>>, StoreError> {
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
|
|
||||||
StoreId::new(Some(rt.store().path().clone()), PathBuf::from(name))
|
debug!("Getting: {:?}", name);
|
||||||
.and_then(|id| rt.store().get(id))
|
let result = StoreId::new(Some(rt.store().path().clone()), PathBuf::from(name))
|
||||||
|
.and_then(|id| rt.store().get(id));
|
||||||
|
|
||||||
|
debug!(" => : {:?}", result);
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
|
fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
|
||||||
|
@ -128,10 +133,14 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
|
||||||
{
|
{
|
||||||
let mut from_entry = match get_entry_by_name(rt, from).map_err_trace_exit_unwrap(1) {
|
let mut from_entry = match get_entry_by_name(rt, from).map_err_trace_exit_unwrap(1) {
|
||||||
Some(e) => e,
|
Some(e) => e,
|
||||||
None => warn_exit("No 'from' entry", 1),
|
None => {
|
||||||
|
debug!("No 'from' entry");
|
||||||
|
warn_exit("No 'from' entry", 1)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
for entry in to {
|
for entry in to {
|
||||||
|
debug!("Handling 'to' entry: {:?}", entry);
|
||||||
if PathBuf::from(entry).exists() {
|
if PathBuf::from(entry).exists() {
|
||||||
debug!("Linking externally: {:?} -> {:?}", from, entry);
|
debug!("Linking externally: {:?} -> {:?}", from, entry);
|
||||||
let url = Url::parse(entry).unwrap_or_else(|e| {
|
let url = Url::parse(entry).unwrap_or_else(|e| {
|
||||||
|
@ -312,6 +321,10 @@ mod tests {
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
use libimagstore::store::{Result as StoreResult, FileLockEntry, Entry};
|
use libimagstore::store::{Result as StoreResult, FileLockEntry, Entry};
|
||||||
|
|
||||||
|
fn setup_logging() {
|
||||||
|
let _ = ::env_logger::try_init();
|
||||||
|
}
|
||||||
|
|
||||||
make_mock_app! {
|
make_mock_app! {
|
||||||
app "imag-link";
|
app "imag-link";
|
||||||
modulename mock;
|
modulename mock;
|
||||||
|
@ -327,8 +340,14 @@ mod tests {
|
||||||
|
|
||||||
let default_entry = Entry::new(StoreId::new_baseless(PathBuf::from("")).unwrap()).to_str();
|
let default_entry = Entry::new(StoreId::new_baseless(PathBuf::from("")).unwrap()).to_str();
|
||||||
|
|
||||||
|
debug!("Default entry constructed");
|
||||||
|
|
||||||
let id = StoreId::new_baseless(path)?;
|
let id = StoreId::new_baseless(path)?;
|
||||||
|
debug!("StoreId constructed: {:?}", id);
|
||||||
|
|
||||||
let mut entry = rt.store().create(id.clone())?;
|
let mut entry = rt.store().create(id.clone())?;
|
||||||
|
|
||||||
|
debug!("Entry constructed: {:?}", id);
|
||||||
entry.get_content_mut().push_str(&default_entry);
|
entry.get_content_mut().push_str(&default_entry);
|
||||||
|
|
||||||
Ok(id)
|
Ok(id)
|
||||||
|
@ -351,77 +370,111 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_link_modificates() {
|
fn test_link_modificates() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
|
|
||||||
|
debug!("Entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
||||||
|
|
||||||
|
debug!("Linking done");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
||||||
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_ne!(*test_links1, links_toml_value(vec![]));
|
assert_ne!(*test_links1, links_toml_value(vec![]));
|
||||||
assert_ne!(*test_links2, links_toml_value(vec![]));
|
assert_ne!(*test_links2, links_toml_value(vec![]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_linking_links() {
|
fn test_linking_links() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
|
|
||||||
|
debug!("Test entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
||||||
|
|
||||||
|
debug!("Linking done");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
||||||
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_eq!(*test_links1, links_toml_value(vec!["test2"]));
|
assert_eq!(*test_links1, links_toml_value(vec!["test2"]));
|
||||||
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multilinking() {
|
fn test_multilinking() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
|
|
||||||
|
debug!("Test entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
||||||
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
||||||
|
|
||||||
|
debug!("Linking done");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
||||||
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_eq!(*test_links1, links_toml_value(vec!["test2"]));
|
assert_eq!(*test_links1, links_toml_value(vec!["test2"]));
|
||||||
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_linking_more_than_two() {
|
fn test_linking_more_than_two() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2", "test3"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2", "test3"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
let test_id3 = create_test_default_entry(&rt, "test3").unwrap();
|
let test_id3 = create_test_default_entry(&rt, "test3").unwrap();
|
||||||
|
|
||||||
|
debug!("Test entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
||||||
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
||||||
|
|
||||||
|
debug!("Linking done");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
|
@ -431,6 +484,8 @@ mod tests {
|
||||||
let test_entry3 = rt.store().get(test_id3).unwrap().unwrap();
|
let test_entry3 = rt.store().get(test_id3).unwrap().unwrap();
|
||||||
let test_links3 = get_entry_links(&test_entry3).unwrap();
|
let test_links3 = get_entry_links(&test_entry3).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_eq!(*test_links1, links_toml_value(vec!["test2", "test3"]));
|
assert_eq!(*test_links1, links_toml_value(vec!["test2", "test3"]));
|
||||||
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
assert_eq!(*test_links2, links_toml_value(vec!["test1"]));
|
||||||
assert_eq!(*test_links3, links_toml_value(vec!["test1"]));
|
assert_eq!(*test_links3, links_toml_value(vec!["test1"]));
|
||||||
|
@ -440,45 +495,65 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_linking_links_unlinking_removes_links() {
|
fn test_linking_links_unlinking_removes_links() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
|
|
||||||
|
debug!("Test entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2"].into_iter());
|
||||||
|
|
||||||
|
debug!("Linking done");
|
||||||
|
|
||||||
let rt = reset_test_runtime(vec!["remove", "test1", "test2"], rt)
|
let rt = reset_test_runtime(vec!["remove", "test1", "test2"], rt)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
remove_linking(&rt);
|
remove_linking(&rt);
|
||||||
|
|
||||||
|
debug!("Linking removed");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
let test_entry2 = rt.store().get(test_id2).unwrap().unwrap();
|
||||||
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
let test_links2 = get_entry_links(&test_entry2).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_eq!(*test_links1, links_toml_value(vec![]));
|
assert_eq!(*test_links1, links_toml_value(vec![]));
|
||||||
assert_eq!(*test_links2, links_toml_value(vec![]));
|
assert_eq!(*test_links2, links_toml_value(vec![]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_linking_and_unlinking_more_than_two() {
|
fn test_linking_and_unlinking_more_than_two() {
|
||||||
let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2", "test3"])
|
setup_logging();
|
||||||
|
let rt = generate_test_runtime(vec!["internal", "test1", "test2", "test3"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
debug!("Runtime created");
|
||||||
|
|
||||||
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
let test_id1 = create_test_default_entry(&rt, "test1").unwrap();
|
||||||
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
let test_id2 = create_test_default_entry(&rt, "test2").unwrap();
|
||||||
let test_id3 = create_test_default_entry(&rt, "test3").unwrap();
|
let test_id3 = create_test_default_entry(&rt, "test3").unwrap();
|
||||||
|
|
||||||
|
debug!("Test entries created");
|
||||||
|
|
||||||
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter());
|
||||||
|
|
||||||
|
debug!("linking done");
|
||||||
|
|
||||||
let rt = reset_test_runtime(vec!["remove", "test1", "test2", "test3"], rt)
|
let rt = reset_test_runtime(vec!["remove", "test1", "test2", "test3"], rt)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
remove_linking(&rt);
|
remove_linking(&rt);
|
||||||
|
|
||||||
|
debug!("linking removed");
|
||||||
|
|
||||||
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
let test_entry1 = rt.store().get(test_id1).unwrap().unwrap();
|
||||||
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
let test_links1 = get_entry_links(&test_entry1).unwrap();
|
||||||
|
|
||||||
|
@ -488,6 +563,8 @@ mod tests {
|
||||||
let test_entry3 = rt.store().get(test_id3).unwrap().unwrap();
|
let test_entry3 = rt.store().get(test_id3).unwrap().unwrap();
|
||||||
let test_links3 = get_entry_links(&test_entry3).unwrap();
|
let test_links3 = get_entry_links(&test_entry3).unwrap();
|
||||||
|
|
||||||
|
debug!("Asserting");
|
||||||
|
|
||||||
assert_eq!(*test_links1, links_toml_value(vec![]));
|
assert_eq!(*test_links1, links_toml_value(vec![]));
|
||||||
assert_eq!(*test_links2, links_toml_value(vec![]));
|
assert_eq!(*test_links2, links_toml_value(vec![]));
|
||||||
assert_eq!(*test_links3, links_toml_value(vec![]));
|
assert_eq!(*test_links3, links_toml_value(vec![]));
|
||||||
|
|
|
@ -39,10 +39,12 @@ This section contains the changelog from the last release to the next release.
|
||||||
address and either shows or lists the found contacts
|
address and either shows or lists the found contacts
|
||||||
* `imag-contact list` and `imag-contact find` is now able to print the
|
* `imag-contact list` and `imag-contact find` is now able to print the
|
||||||
output as JSON.
|
output as JSON.
|
||||||
* `imag-edit` can now read store ids from stdin, sorts
|
* `imag-edit` can now read store ids from stdin, so
|
||||||
`imag ids | fzf | imag edit -I` is not a thing.
|
`imag ids | fzf | imag edit -I` is now a thing.
|
||||||
* `imag ids` does not print the path of the store. Can be turned on using
|
* `imag ids` does not print the path of the store. Can be turned on using
|
||||||
commandline flag.
|
commandline flag.
|
||||||
|
* `imag-habit today --done` and `imag-habit status --done` was added for
|
||||||
|
showing habits which are already done.
|
||||||
* Minor changes
|
* Minor changes
|
||||||
* A license-checker was included into the CI setup, which checks whether all
|
* A license-checker was included into the CI setup, which checks whether all
|
||||||
".rs"-files have the license header at the top of the file
|
".rs"-files have the license header at the top of the file
|
||||||
|
@ -61,6 +63,8 @@ This section contains the changelog from the last release to the next release.
|
||||||
* `imag-tag` commandline was rewritten for positional arguments.
|
* `imag-tag` commandline was rewritten for positional arguments.
|
||||||
* `libimagrt` automatically takes "rt.editor" into account when building
|
* `libimagrt` automatically takes "rt.editor" into account when building
|
||||||
editor object
|
editor object
|
||||||
|
* `libimagentryref` got a utility function for making an entry a ref.
|
||||||
|
* `libimaghabit` got `Habit::instance_exists_for_date()`
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
* imag does not panic anymore when piping and breaking that pipe, for
|
* imag does not panic anymore when piping and breaking that pipe, for
|
||||||
example like with `imag store ids | head -n 1`.
|
example like with `imag store ids | head -n 1`.
|
||||||
|
@ -84,6 +88,10 @@ This section contains the changelog from the last release to the next release.
|
||||||
editor command.
|
editor command.
|
||||||
* `libimagrt` produced the editor command without taking arguments into
|
* `libimagrt` produced the editor command without taking arguments into
|
||||||
account.
|
account.
|
||||||
|
* `libimagentryref` got a fix where the buffer for the hash calculation was
|
||||||
|
not allocated properly.
|
||||||
|
* `libimagstore::store::Store::create` overwrote existing entries.
|
||||||
|
* `libimaghabit::habit::HabitTemplate` did not link new instances.
|
||||||
|
|
||||||
|
|
||||||
## 0.6.3
|
## 0.6.3
|
||||||
|
|
|
@ -198,7 +198,7 @@ mod compile_test {
|
||||||
use storeid::StoreId;
|
use storeid::StoreId;
|
||||||
|
|
||||||
fn store() -> Store {
|
fn store() -> Store {
|
||||||
unimplemented!()
|
unimplemented!("Not implemented because in compile-test")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_compile_get() {
|
fn test_compile_get() {
|
||||||
|
|
|
@ -348,6 +348,7 @@ pub mod builder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = ::kairos::parser::parse(&recur) {
|
if let Err(e) = ::kairos::parser::parse(&recur) {
|
||||||
|
debug!("Kairos failed: {:?}", e);
|
||||||
return Err(e).map_err(From::from);
|
return Err(e).map_err(From::from);
|
||||||
}
|
}
|
||||||
let date = date_to_string(&dateobj);
|
let date = date_to_string(&dateobj);
|
||||||
|
|
|
@ -91,6 +91,7 @@ macro_rules! make_unique_ref_path_generator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unique_hash<A: AsRef<Path>>(path: A) -> Result<String, Self::Error> {
|
fn unique_hash<A: AsRef<Path>>(path: A) -> Result<String, Self::Error> {
|
||||||
|
debug!("Making unique hash for path: {:?}", path.as_ref());
|
||||||
$impl(path)
|
$impl(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +136,8 @@ macro_rules! make_unique_ref_path_generator {
|
||||||
$collectionname
|
$collectionname
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unique_hash<A: AsRef<Path>>(path: A) -> Result<String, Self::Error> {
|
fn unique_hash<A: AsRef<Path>>(path: A) -> ::std::result::Result<String, Self::Error> {
|
||||||
|
debug!("Making unique hash for path: {:?}", path.as_ref());
|
||||||
$impl(path)
|
$impl(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +200,7 @@ macro_rules! make_sha_mod {
|
||||||
|
|
||||||
/// Function which can be used by a wrapping UniqueRefPathGenerator to hash only N bytes.
|
/// Function which can be used by a wrapping UniqueRefPathGenerator to hash only N bytes.
|
||||||
pub fn hash_n_bytes<A: AsRef<Path>>(path: A, n: usize) -> Result<String, RE> {
|
pub fn hash_n_bytes<A: AsRef<Path>>(path: A, n: usize) -> Result<String, RE> {
|
||||||
|
debug!("Opening '{}' for hashing", path.as_ref().display());
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.write(false)
|
.write(false)
|
||||||
|
@ -233,8 +236,13 @@ macro_rules! make_sha_mod {
|
||||||
make_sha_mod! {
|
make_sha_mod! {
|
||||||
sha1, Sha1, |buffer: String| {
|
sha1, Sha1, |buffer: String| {
|
||||||
let mut hasher = ::crypto::sha1::Sha1::new();
|
let mut hasher = ::crypto::sha1::Sha1::new();
|
||||||
|
|
||||||
|
trace!("Hashing: '{:?}'", buffer);
|
||||||
hasher.input_str(&buffer);
|
hasher.input_str(&buffer);
|
||||||
Ok(String::from(hasher.result_str()))
|
let res = hasher.result_str();
|
||||||
|
trace!("Hash => '{:?}'", res);
|
||||||
|
|
||||||
|
Ok(String::from(res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,4 +44,5 @@ pub mod date;
|
||||||
pub mod datetime;
|
pub mod datetime;
|
||||||
pub mod parse;
|
pub mod parse;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
|
pub mod ui;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn time_ui_fmtstr() -> &'static str {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time_ui_fmtstr_expl() -> &'static str {
|
pub fn time_ui_fmtstr_expl() -> &'static str {
|
||||||
#r"In the UI, the format for Time is always YEAR-MONTH-DAY.
|
r#"In the UI, the format for Time is always YEAR-MONTH-DAY.
|
||||||
Optionally, Time can be specified by seperating it from the date with 'T'.
|
Optionally, Time can be specified by seperating it from the date with 'T'.
|
||||||
Minutes and Seconds are optional.
|
Minutes and Seconds are optional.
|
||||||
"#
|
"#
|
||||||
|
|
Loading…
Reference in a new issue