Commit Graph

100 Commits

Author SHA1 Message Date
Matthias Beyer 604f350340 Add logging in store 2018-04-14 16:55:36 +02:00
Matthias Beyer e61ccc9561 Fix: Entry::to_str() should return Result<_>
Because serializing might fail.

Also fixes all usages of the API.
2018-03-26 14:24:42 +02:00
Matthias Beyer 9e0d0d9f6c Add Entry::replace_from_buffer() 2018-03-23 15:44:34 +01:00
Matthias Beyer 7e623f39b8 Add message why panic
So we see that when grepping the source for `unimplemented!()`.
2018-03-23 10:05:58 +01:00
Matthias Beyer 41f7bab1c5 Fix: Store::create() should fail if the entry exists 2018-03-22 21:16:11 +01:00
Matthias Beyer 68ace5d147 Fix typo 2018-03-12 13:32:23 +01:00
Matthias Beyer da408b9e67 This fixes the file parsing (again)
Unfortunately, our latest fix to file parsing did not solve all issues.
So we have to fix it _again_.

The problem was the `std::str::Lines` iterator, which apparently fails
this:

    assert_eq!(1, "".lines().count());

as an empty line seems not to be a line.

Because of that, when reading a file with an empty line at its bottom
got stripped off that line.

This patch removes the use of the `lines()` iterator and uses
`split("\n")` instead. This only works on Unix operating systems, but as
we only target unix operating systems with imag, this is not considered
an issue right now.

This patch also adds extensive tests on multiple levels in the
`libimagstore` implementation:

* On the parsing level, for the function which implements the parsing
* On the filesystem abstraction levels
* On the `Store` levels

to make sure that everything is parsed correctly.
2018-03-10 14:53:15 +01:00
Matthias Beyer 579c00b62a Replace hard coded version strings with compiletime env 2018-03-06 12:45:41 +01:00
Matthias Beyer ee5a17790f Fix multi-line reading
Reading entries with multiple entries caused all lines to be read as one
line.

This bug is fixed with this patch.
2018-03-02 21:48:17 +01:00
Matthias Beyer 87d6f1221f Add testcase for reading multiple lines 2018-03-02 21:48:13 +01:00
Matthias Beyer 9fb5f453fe Rewrite entry parsing algorithm
Rewrite without regex crate.

The regex approach was broken. If the following _content_ was provided
in the entry:

    foo

    ---

    bar

The regex approach parsed the header until the "---" in the content.
This is, of course, not the way to do that.

Now, the parsing is implemented by hand. Should be faster as well,
though I don't care about this.

This fixes a severe bug.
2018-02-20 21:06:36 +01:00
Matthias Beyer 5f99018807 Simplify store debug print 2018-02-19 11:51:21 +01:00
Matthias Beyer 9e3c966d84
Merge pull request #1273 from matthiasbeyer/update-version-numbers
Update version string: 0.6.0 -> 0.7.0
2018-02-11 17:50:52 +01:00
Matthias Beyer 30d2c28a22 Update version string: 0.6.0 -> 0.7.0 2018-02-11 14:22:24 +01:00
Matthias Beyer 8fcd2a6c8c Prettify Store debug output implementation 2018-02-11 13:36:37 +01:00
Matthias Beyer d5a9e4930d Update dates in license header
And add missing header in one file
2018-02-07 02:48:53 +01:00
Matthias Beyer de613c9ebd
Merge pull request #1227 from matthiasbeyer/libimagentryutil/filtered-iterators
libimagentryutil: filtered iterators
2018-02-01 20:22:12 +01:00
Matthias Beyer 06cb8d50fb Make StoreId::is_in_collection() generic over AsRef<str> 2018-02-01 16:46:57 +01:00
Matthias Beyer b3f546129a Add StoreIdIteratorWithStore::without_store() 2018-02-01 16:46:38 +01:00
Matthias Beyer 8e931cd79f Change calls to into_get_iter() to not take argument 2018-02-01 16:46:38 +01:00
Matthias Beyer 3b01a9eb2f Add API in StoreIdIteratorWithStore to get acting iterators
This patch adds API functions in the StoreIdIteratorWithStore iterator
type to transform it into a iterator which _does_ something (as in the
`libimagstore::iter` API).

It mimics the API which is offered by `libimagstore::iter`.
2018-02-01 15:47:39 +01:00
Matthias Beyer 030e32e44f Provide StoreId Iterator which has a ref to the Store
This change is needed so we can refactor the "get" iterator to not take
an argument (the store) later, which improves the API.
2018-02-01 15:47:39 +01:00
Matthias Beyer 164b6b7f10 Move documentation to appropriate place 2018-01-29 09:38:32 +01:00
Matthias Beyer fcfc397fc8 env_logger: 0.5.0-rc.2 -> 0.5 2018-01-18 14:15:40 +01:00
Matthias Beyer 8d9c7dce4f env_logger: 0.5.0-rc.1 -> 0.5.0-rc.2 2018-01-15 11:22:09 +01:00
Matthias Beyer 635d000344 log: 0.4.0-rc.1 -> 0.4.0 2018-01-15 11:21:52 +01:00
Matthias Beyer c45130ddd0 env_logger: 0.4.* -> 0.5.0-rc.1 2018-01-15 11:20:27 +01:00
Matthias Beyer f209e12410 Update dependency: log: 0.3.* -> 0.4.0-rc.1 2018-01-15 11:20:07 +01:00
Matthias Beyer 3ef5fcfab6 libimagstore: Replace read with typed read 2018-01-13 01:14:03 +01:00
Matthias Beyer 0c4be78223 Update dependency: toml-query -> 0.6 2018-01-13 01:14:03 +01:00
Matthias Beyer bfc35e0517 Remove dependency "version"
Because the "version" crate is licensed as GPL, which would us require
to release imag as GPL, we remove the crate now.
2018-01-12 13:33:40 +01:00
Matthias Beyer 689310edfe Rename `Store::retrieve_copy` to `Store::get_copy`
The function was named falsely and nobody noticed. So nobody uses this
function yet - hopefully - as this change is a breaking API change.
2018-01-08 15:16:41 +01:00
Matthias Beyer 7d1d41884c Replace matching with function chaining 2018-01-05 11:37:09 +01:00
Matthias Beyer 774933ae4a
Merge pull request #1163 from matthiasbeyer/libimagstore/mighty-iters
libimagstore: More powerful iterator extensions
2017-12-25 22:02:56 +01:00
Matthias Beyer 9890371652
Merge pull request #1185 from matthiasbeyer/bump-version-strings
Update version strings: 0.5.0 -> 0.6.0
2017-12-25 21:06:14 +01:00
Matthias Beyer 46a8d373b3 Allow dead code in whole module 2017-12-25 19:23:41 +01:00
Matthias Beyer 7d67b67440 Update version strings in tests 2017-12-25 19:17:07 +01:00
Matthias Beyer 3c8dd19d11 Update version strings: 0.5.0 -> 0.6.0 2017-12-25 19:17:07 +01:00
Matthias Beyer 9128d04866 Remove test
This test is not applicable anymore because it tests (and tested) the
wrong thing.

It was to check whether the function failed because the "imag" key
contained the wrong type, but this is not tested by that function. The
function only checks whether the "imag" key is present.
2017-12-25 17:59:50 +01:00
Matthias Beyer 35410aaa2e Refactor: Remove unneccessary functions 2017-12-25 17:59:50 +01:00
Matthias Beyer 20a552f527 Refactor header checking to use toml-query 2017-12-25 17:59:50 +01:00
Matthias Beyer 2bf91fab09 Enhance error types 2017-12-25 17:59:50 +01:00
Matthias Beyer 0870665668 Add iterator extension for iterators over Result<T, E> 2017-12-24 13:52:50 +01:00
Matthias Beyer 67410b3ad2 Implement iter extension for all iterators over StoreId 2017-12-24 13:52:50 +01:00
Matthias Beyer 0ed636bb06 Refactor libimagrt+libimagstore to pass whole configuration object
Before we extracted the store configuration from the configuration
toml::Value object and passed it to the store.

This is unecessary overhead.

Now we pass the whole configuration object and let the store extract the
required values.
2017-12-24 13:52:18 +01:00
Matthias Beyer 174d8d76e9 Remove configuration member, reduce configuration
We only need the configuration to check whether creating the store
directory is actually allowed.
2017-12-24 13:52:13 +01:00
Matthias Beyer 38b56df406 Add new dependency: toml-query 2017-12-24 13:52:13 +01:00
Matthias Beyer af67ff51c8 Remove accidentially slipped-in println!() 2017-12-06 19:51:02 +01:00
Matthias Beyer 77f93e77f0 Fix syntax 2017-11-18 12:28:20 +01:00
Matthias Beyer dc26f8c20c
Merge pull request #1156 from matthiasbeyer/store-verify-from-cli-app
Move verify implementation from Store to CLI interface
2017-10-31 15:47:57 +01:00