summaryrefslogtreecommitdiffstats
path: root/lib/core
AgeCommit message (Collapse)Author
2019-12-23Remove unnecessary clone() callMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-12-23Remove DebugResult and DebugOption helpersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-12-23Replace map_dbg() and map_dbg_str() with context() and inspect() callsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-12-23Replace map_dbg_err() calls with context() callsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-12-22Fix: Ignore broken pipe when reporting idsMatthias Beyer
This fixes a bug where a broken pipe in Runtime::report_touched() resulted in an Err(_) raised up to main() which then reported this. But as report_touched() should ignore a broken pipe (because the program will exit anyways shortly after the call), we can safely ignore this error. This also results in `ExitCode` removed from the function signature, which pushes us forward to the removal of custom error-handling implementations! Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-11-09Add Runtime::input_is_pipe()Matthias Beyer
We need this because we might want to check whether we can get the STDIN handle from the runtime or not. In some (rare) cases, the runtime "thinks" that STDIN is a stream of IDs, but it is not. So the client can check whether stdin is a pipe (thus, whether Runtime thinks that there's a stream of IDs) and easily work around that by taking ::std::io::stdin() itself. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-27Add extension trait for iterator over Result<Entry>Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-27Add iterator extensions for store-id touched reportingMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Revert "Add extension traits for handling Result<Option<T>, E> conversion"Matthias Beyer
This reverts commit d810b63886f4006d01bca894982bbc867616f37c. As resiter v0.4.0 does provide this extension now, we don't need it in the codebase anymore.
2019-10-26Add extension traits for handling Result<Option<T>, E> conversionMatthias Beyer
This extension traits help transforming Result<Option<T>, E> to Result<T, E> or transforming an iterator over the former type to an iterator over the latter type. Should be moved to resiter of course, but we need to implement this first. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Implement Error for ExitCodeMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Add Entry::set_content()Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Add ImagApplication trait for CLI completion + single-binary supportLeon Schuermann
To re-add the imag-binary CLI completion, as well as to enable building a single imag containing all of the subcommands, this commit introduces an ImagApplication trait to be implemented by all imag binary crates. The binary crates will be converted to libraries, with an additional binary target. This enables standalone and single binary builds. On its own, this commit doesn't do much, but rather it paves the way to dynamically interacting with the imag uis/clis using a library-crate interface. Signed-off-by: Leon Schuermann <leon@is.currently.online>
2019-10-26Add some debug outputMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Fix test: Check whether in cache, then get, then check againMatthias Beyer
After moving an entry, the entry should _not_ be in the cache. This is just a decision that has to be made, whether we cache the moved entry or not. I decided to not cache because it is results in less code. After that check, we get the entry from the backend and then we can check whether the entry is in the cache, which is then should be. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Add test: Test moving entry with writing to it before and after movingMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Fix: Testing backend bug where an entry was not properly rewrittenMatthias Beyer
When moving an entry, what we did is copying the entry inside the backend abstraction (the hashmap) from one key to another. But as the entry itself does also encode its location, we actually have to rewrite the entire entry. This patch fixes this. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26Fix: Renaming entries should also remove the old entryMatthias Beyer
This is a bugfix for a bug in Store::move_entry_by_id(): The old entry was not removed after the new one was created. The bug is a bit subtle. The issue was, that the internal cache held open a reference to the old entry (as StoreEntry object) and when that object got drop()ed, the contents of the entry were written to disk, which resulted in the old entry being recreated. This patch rewrites the function to behave well. The most critical part is that we do not check whether the old entry is borrowed with `hsmap.get()` but rather `hsmap.remove()`. The trick here is that the `StoreEntry` object is dropped in the moment the check is done, clearing the cached object and flushing it to the backend (the disk). After that, we continue doing the filesystem operation and the cache is clean. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-13Fix: --override-config argument can be passed multiple timesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-07Update dependency: ansi_term: 0.11.0 -> 0.12Matthias Beyer
2019-10-07Update dependency: handlebars: 1.1.0 -> 2Matthias Beyer
2019-10-07Update dependency: env_logger: 0.6.1 -> 0.7Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-09-01Add Tests for Entries::{find_by_id_substr, find_by_id_startswith}Matthias Beyer
2019-09-01Add Entries::{find_by_id_substr, find_by_id_startswith}Matthias Beyer
This patch adds functions to the Entries type which can be used for filtering by id, either with `contains()` or `starts_with()`. This is useful for the end-user functionality where the user specifies the ID of an entry only partially. The implementation still iterates over all entries. This could be improved, of course, by implementing a `find`-like function on `Store` directly. But for now, this is good enough. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28[No-auto] lib/core/store: Fix Clippy warningsflip1995
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28[No-auto] lib/core/rt: Fix Clippy warningsflip1995
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28[Auto] lib/core/rt: Fix Clippy warningsflip1995
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28[Auto] lib/core/error: Fix Clippy warningsflip1995
Signed-off-by: flip1995 <hello@philkrones.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-25Run "cargo fix --all-features" in root of projectMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-26Refactor: Do not provide functions for these identifiersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-25Add checks whether variables are valid unicode and propagate appropriate errorMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-24Rewrite get_rtp_match() to not panicMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-30Remove use of ItertoolsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-30Update all dependenciesMatthias Beyer
This patch updates all dependencies but not "nom". Done with `cargo upgrade --all` and manual editing. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-22Allow unused variable hereMatthias Beyer
2019-05-31Import toml-query with typed featureMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Rewrite to use derive macroMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Add comment why we do thisMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Remove boilerplate by enabling serde in "log" dependencyMatthias Beyer
This patch adds the "serde" feature to the "log" dependency, so we can deserialize logging levels directly into "log" types. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Rewrite logging config deserializationMatthias Beyer
This patch rewrites the logging config deserialization. It removes the manual traversing of the config toml structure and replaces it with types which implement `Deserialize`, which is way more convenient and easy to read (and extend). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29Update toml-query to 0.9.0Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29Update dependency: toml: 0.4 -> 0.5Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-24Introduce proper error handling in IdPathProviderLeon Schuermann
Prior to this change, the IdPathProvider implementation would be responsible for exiting the process on insufficient / wrong arguments. However, such error handling should be performed together with the business logic and not in CLI-parsing related code. This change introduces a clear separation: both parsing errors and insufficient id path arguments can now be return from inside the `get_ids`-method, and get passed up to the application logic to be handled. This change is reflected in all instances of IdPathProvider and their surrounding code. Signed-off-by: Leon Schuermann <leon.git@is.currently.online> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Fix: Entries::in_collection() should be able to return errorMatthias Beyer
This patch changes the Entries::in_collection() interface to return a Result<()>. This is needed because the fs backend implementation should be able to check whether a directory actually exists whenever we change the iterator. If the implementation detects that the directory does not exist, we can fail early and error out. All usages of the interface are adapted by the patch as well. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Add more context in error messagesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Add more context in error messagesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Run 'cargo fix' for rust-2018Matthias Beyer
With this patch we move the codebase to Rust-2018. The diff was generated by executing cargo fix --all --all-features --edition on the codebase. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13Merge branch 'fix-path-iterator' into master-ffMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13Fix: PathIterBuilder should not yield directoriesMatthias Beyer
PathIterBuilder should yield iterator that does only yield file pathes, not directories. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13Rewrite all usages of ModuleEntryPathMatthias Beyer
Because the code was so complex before, we had to create an object and then cast that object into a `StoreId` rather than just creating a `StoreId` object right away. With this patch, we're using the code-generation approach to generate a function that creates a `StoreId` object based on the name of the current module. That's way easier and error handling was also improved by the switch to the new implementation. The patch also includes a rewrite of all usages of ModuleEntryPath and changes them to `module_path::new_id()` calls. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>