Commit Graph

5816 Commits

Author SHA1 Message Date
Matthias Beyer 6681f9fcfd Remove unused code
Because the store is more efficient when reading and writing entries to
disk, we do not need to flush the cache anymore.

Hence, remove the flushing.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-18 16:02:49 +01:00
Matthias Beyer b5fe48b564 Remove serializing where result was unused
I'm not sure why this was still there, it seems that this was left out
when deleting older code.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-18 16:02:49 +01:00
Matthias Beyer c562f35222 Merge branch 'rewrite-libimagentryref'
This is the merge for the "ref"-infrastructure rewrite. Finally.

The refs are now stored with three bits of information:

    * The "collection" (named basepath)
    * The "relpath" (relative path)
    * The hash (sha1 as of now)

The "collection" is a name which has to be accociated with a path to a
directory (in the config file).
That gives the user the opportunity to have (for example) their music
collection in $HOME/music on one device and in $HOME/media/music on
another.
The "relpath" is the relative path, which results in the path to the
actual file when being joined with the "collection" path.

The hash is a sha1 hash as of now. Re-checking this hash with
libimagentryref is not yet tested.

This merge also removes the "mail" code completely, for the sake of
seperating concerns into branches. The respective commits might be
removed later.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:44:54 +01:00
Matthias Beyer f9a980c344 Remove imag-mail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:49 +01:00
Matthias Beyer 74045e1800 Remove libimagmail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer 49df7f54a9 Rewrite imag-ref 2019-02-17 11:09:48 +01:00
Matthias Beyer ac5a3c0298 Reimplement LinkProcessor::process() for new libimagentryref API
The documentation of the function kind of explains why this change is
necessary. It might get changed in the future so that the user has more
flexibility.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer d8ad741fc2 Rewrite libimagentrymarkdown imports 2019-02-17 11:09:48 +01:00
Matthias Beyer db7121ccba Rewrite library
* Remove old code
* Rewrite with tests

This implements a fassade pattern for ref library

With the fassade, we can specify the hasher in a rather easy way, which
is not possible with default generics for traits.

The "default" part in "default generic type" is not properly implemented
yet (as visible in the tests), as I don't know how to realize this.

For simplicity, the `hasher` module exports a `default` module with a
`DefaultHasher` type, which resolves to the `Sha1Hasher`.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer a41479c0ec doc: Rewrite README for libimagentryref 2019-02-17 11:09:48 +01:00
Matthias Beyer 820ac41443 Add trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 10:47:46 +01:00
Matthias Beyer 84c6a1981e Fix: If the field is not available, return false
The function is for checking whether a flag is set. If the flag is not
available, the flag is obviously not set.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 10:47:46 +01:00
Matthias Beyer a6ad19a14f Merge branch 'redefine-storeid'
Finally merging the redefine of the StoreId implementation, which allows
easier handling of StoreId objects.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:58 +01:00
Matthias Beyer 08b7a46c74 Use StoreId::local_display_string() for less errorhandling here
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:06 +01:00
Matthias Beyer 9af7e9a9ab Remove unused variable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:06 +01:00
Matthias Beyer 6fd2c9b958 Remove irrelevant tests
Because StoreId objects do not contain bases anymore, we do not need
these tests anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:10:49 +01:00
Matthias Beyer 06185fc44f Merge branch 'imag-header' into master-ff
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 21:54:10 +01:00
Matthias Beyer aa5ea533c7 Add imag-header
imag-header is a tool for querying information of an entry in a defined
format.

imag-header is intended for scripting with imag commands.
The output format is not stable yet, though.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:54:52 +01:00
Matthias Beyer 0888e4345c Use StoreId::local_display_string() for less errorhandling here
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer f558556b3a Fix for new all_annotations() interface
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 444ca2d424 Adapt to new all_contacts() return type
because we return `libimagstore::iter::Entries` here now, we do not have
to pass the store anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 8fb4bcf0c6 Fix for new StoreId::new() interface
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 1bbd2173b7 Fix for new StoreId::new() interface
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 5fe139e02b Adapt StoreId::new() calls
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 39d638daee Adapt for new StoreId API
When printing the storepath with the ID (when requested by the user), we
have to ask the store for its path.

This is a rather naive implementation which could be improved by only
checking for a boolean in the last iteration and then use a prepared
variable, rather than making the storepath part of the iterator.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 972cba7c31 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 207fd88c3d Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer d2c031920a Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer ebf3f309a6 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 187b948985 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 83415e78b9 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer f64b87b4a8 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer c6cc1804e7 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b4f401675e Add Entries::into_storeid_iter()
This is a more complicated functionality (implementation-wise) of the
`Entries` iterator, which allows a callee to transform it into a
`StoreIdIterator`.

It uses the crate internal `PathIterator` type and a function to extract
the internals of that iterator which is then turned into an iterator
over `Result<StoreId>`, which can be used to build a `StoreIdIterator`.

The implementation is ugly, but we need to be able to transform a
`Entries` iterator into a `StoreIdIterator` in the
`libimagentryannotation`, and possibly in more cases where we want to be
agnostic over iterators.

Maybe there is a cleaner solution to this, hence the comment about
whether this should be removed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 2e7c17d5dc Fix libimagcontact for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b383e082fb Fix libimagtodo for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 14a2485a8a Change signature: Link::exists(&Store)
This change is necessary because we need the store now to check whether
a StoreId exists.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 429ef9bc4c Fix libimagentrylink for new StoreId API
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 642702b724 Rewrite: StoreId::new_baseless() -> StoreId::new()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer b66371f79b Rewrite Store::new* API: libimagstore does not export backend types
With this change applied, libimagstore does not export backend
representing types anymore.

This change is necessar because when we want to switch the `StoreId`
implementation from "complex and stateful" to "Stateless and Cow<'_,
&str>", we need to be able to have a type which represents a "`StoreId`
plus the path of the Store itself".
This "the path of the Store itself" is passed around as reference, to
minimize runtime impact.

Because such a type should not be exported by the libimagstore crate, we
make it `pub(crate)` internally. But because the backend APIs also have
to use this type, we would export the (private) type in the APIs of the
backend.

Because of that we make the backend API also non-visible to crate users,
which also decreases the surface of the libimagstore API itself.

Besides:
Remove function `Link::with_base()` which is not needed anymore (was
used in tests only).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 35a500f91c Delete unused code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 04a8c5f721 Move to simpler implementation of Storeid
This changes the implementation of the StoreId type to be less complex.
Before we always had to re-attach the path of the store itself each time
a StoreId object was passed to the store. Now we do not do this anymore,
hopefully we can move to a implementation of the Store API which takes
references of StoreId objects in the future.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer dc162cb167 Fix: Off by one error
When printing the error chain, we print the error and then iterate over
the causes. Hence, we have to increase the printed number by one here,
because 0 (zero) is already printed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:56:13 +01:00
Matthias Beyer 2611583839 Fix: Also print if runtime ignores IDs
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:13:29 +01:00
Matthias Beyer 45cb122f53 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:05:09 +01:00
Matthias Beyer 0916c92a18 Bugfix: Rebuild iterator when changing collection
This patch fixes a bug where the following code (here pseudocode) did
the wrong thing:

    store.entries().in_collection("foo").for_each(||...)

because the `.in_collection()` call for the underlying PathIterator
object did not actually re-build the iterator. It only changed the
contained `PathIterBuilder`, but did not call `.build_iter()` on it to
rebuild the iterator object.

The test added with this patch checks whether the iterator does the
right thing.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 18:29:15 +01:00
Matthias Beyer 2a07c8a0c2 Do not use deprecated way of checking whether path exists
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-12 19:04:15 +01:00
Matthias Beyer 86dca4887d Fix negation error
We Iterator::filter here, so we have to negate - because we list
everything where _no_ instance exists yet.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 334e9e3954 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer c98ec920a3 Adapt for new interface of gen_vars() function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00