Commit Graph

326 Commits

Author SHA1 Message Date
Matthias Beyer c7f5420c1d Change is_log() implementation to use kindflag utility
This patch changes the Log::is_log() implementation for Entry to use the
provide_kindflag_path!() infrastructure.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:52:13 +02:00
Matthias Beyer 1d89844613 Run 'cargo fix' for rust-2018
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-05-18 00:20:59 +02:00
Matthias Beyer ff5e6653ed Add option to override ref data in contact entries
This patch adds a flag to the ContactStore::retrieve* functions so one
can override the ref data in the store for the retrieved entry.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 14:37:43 +02:00
Matthias Beyer 1c851bbb79 Rewrite store interface abstraction
Because we pull in libimagentryref here to create actual references to
the files we parse here, we need to rewrite the interface to be able to
pass the required information to the libimagentryref API.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 14:26:56 +02:00
Matthias Beyer b8cd9c6efa Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer cb4d5367e4 Rewrite all usages of ModuleEntryPath
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>
2019-04-13 22:39:39 +02:00
Matthias Beyer 71cccad665 Remove old comment
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer ca2f130995 Rewrite: Diary::get_youngest_entry_id()
Rewrite to collect not so often internally. This removes one collect()
from the implementation. One is still there in the sorted_by() call,
though.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer 205c2b09b6 Remove outcommented code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:26:21 +01:00
Matthias Beyer ae95022202 Optimize: Do not compute lowercase key twice
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-28 18:07:25 +01:00
Matthias Beyer ce678d6418 Fix: Compare different variables
The bug was that we compared the variable with itself, but one time to
lowercase and one time not, so it was always false.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-24 22:33:41 +01:00
Matthias Beyer ac914b27e2 Merge branch 'libimagmail-better-hash' into master
This merges improvements for the libimagmail hasher.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:34:26 +01:00
Matthias Beyer 211d6fa60b Add helper function to be more flexible
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:31:58 +01:00
Matthias Beyer 596af2fc76 Reimplement the hasher
We create a sha1 over the path of the file and the Message-ID of the
mail itself.

The file name is not constant with mail files, because flags are encoded
in the filename. The path is also not constant with mail files, because
they can be moved between boxes.

This approach is not yet the best one, but better than before.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:30:12 +01:00
Matthias Beyer a819aeb6ed Rewrite libimagmail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +01:00
Matthias Beyer f84cc8169f Revert "Remove libimagmail"
This reverts commit 74045e1800.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +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 74045e1800 Remove libimagmail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +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 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 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 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 45cb122f53 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:05:09 +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 b985c510aa Optimize: Do not iterate over entries outside of "timetrack" collection
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 8a4bc0eba4 Simplify implementation of Wiki::all_ids()
This way we alter the underlying iterator for all wiki entries to only
iterate in the "wiki" collection of the store, which results in fewer
disk access because the internal iterator does not yield all pathes from
the store before filtering them.

Code which was used to implement the filter was removed (also from the
public interface of the library).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer c29e05bc25 Simplify implementation of ContactStore::all_contacts()
This way we alter the underlying iterator for all contacts to only
iterate in the "contact" collection of the store, which results in fewer
disk access because the internal iterator does not yield all pathes from
the store before filtering them.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer 9185abcfa5 Update copyright years
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-01-03 18:41:36 +01:00
Matthias Beyer 496c06d15a Update lazy_static to 1.2
1.2 of lazy_static brings functionality to have no panics in the code,
which is what we try to have.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-11 13:05:55 +01:00
Matthias Beyer 9fca66aa89 Forbid unsafe code in all crates 2018-11-11 13:05:55 +01:00
Matthias Beyer 4e516ee19d Update version strings
...for the next release, which will be imag 0.10.0!

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-10 11:56:37 +01:00
Matthias Beyer 17d4123898 Update dependencies from git versions to proper versions.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-09 22:14:11 +01:00
Matthias Beyer 9cfa9fc399 Make code more idomatic
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-09 21:48:25 +01:00
Matthias Beyer ed469f622a Make code more idomatic
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-09 21:48:02 +01:00
Matthias Beyer 029a3c448e Change WikiStore::create_wiki() interface
to also return the index page. This way a user of the library can use
the index page entry right away.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:35:18 +01:00
Matthias Beyer d1f087eb57 Change libimag{bookmark, entrylink} external linking
...to report newly created entries, so that we can re-use these new
entries in the library-using code (for example for ID reporting).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:33:30 +01:00
Matthias Beyer e043304767 Add FileLockEntry-getter in Mail struct 2018-11-06 14:48:49 +01:00
Matthias Beyer b4068bad0e Remove println call
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-01 21:33:18 +01:00
Matthias Beyer f4ff2ba250 libimagmail: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:29 +01:00
Matthias Beyer d3c0826188 libimagtodo: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:29 +01:00
Matthias Beyer 1956099e2e libimaglog: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 57f7a5a682 libimagtimetrack: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 3951bc7e5d libimagdiary: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 2a107477c0 libimagcontact: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 2dc17f8bea libimagwiki: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 9575bb933d libimagnotes: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer ede70581f3 libimaghabit: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer c11e971139 libimagbookmark: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 5e4779c1f0 Update dependency: filters: 0.2 -> 0.3 2018-10-06 12:22:15 +02:00
Matthias Beyer c7612f156d Update dependency: uuid: 0.6 -> 0.7 2018-10-06 12:22:15 +02:00
Matthias Beyer e8d24634e6 Update dependency: email: 0.0.17 -> 0.0.20 2018-10-06 12:22:15 +02:00
Matthias Beyer c0f74fcbed Update dependencies
log: 0.3 -> 0.4
uuid: 0.6 -> 0.7
2018-10-06 12:22:15 +02:00
Matthias Beyer 695d9f2df8 Update dependency: regex: 0.2 -> 1 2018-10-06 12:21:21 +02:00
Matthias Beyer c162856a21 Update dependencies
regex: 0.2 -> 1
semver: 0.8 -> 0.9
walkdir: 1 -> 2
2018-10-06 12:21:20 +02:00
Matthias Beyer d9e4eaad3c Update kairos to master branch
Because of the new error-chain version which kairos can depend on, for
which kairos is not yet released.
2018-09-27 15:05:45 +02:00
Matthias Beyer 1fa9b86531 Update dependency: lazy_static: 0.2 -> 1 2018-09-27 15:05:45 +02:00
Matthias Beyer f97d9e0d96 Temporarily set vobject to custom fork until we have a new release 2018-09-27 15:05:45 +02:00
Matthias Beyer 946d9891e4 Update dependency: vobject: 0.{4,5} -> 0.6 2018-09-27 15:05:45 +02:00
Matthias Beyer c65e73acc8 Update dependency: kairos: 0.1 -> 0.2 2018-09-27 15:05:45 +02:00
Matthias Beyer 764a019817 Update dependency: log: 0.3 -> 0.4 2018-09-27 15:05:45 +02:00
Matthias Beyer 3d12998603 Update dependency: toml-query: 0.6 -> 0.7 2018-09-27 15:05:44 +02:00
Matthias Beyer 0a7afee454 Update dependency: error-chain: 0.11 -> 0.12 2018-09-27 15:05:25 +02:00
Matthias Beyer d4872f6da3 Optimize the Store::entries() interface
The previous iterator was implemented to simply fetch _all_ pathes from
the filesystem, no matter what.

With this implementation, this changes. The iterator now has
functionality to optimize the iteration, if only a subdirectory of the
store is required, for example `$STORE/foo`.

This is done via functionality where the underlying iterator gets
altered.

First of all, the interface was changed to return a `Entries` object,
which itself only covers the libimagstore-internal `PathIterator` type.
This type was changed so that the backend implementation provides an
"PathIterBuilder`, which builds the actual iterator object for the
`PathIterator` type.

The intermediate `StoreIdConstructingIterator` was merged into
`PathIterator` for simplicity.

The `Entries` type got functionality similar to the
`StoreIdIteratorWithStore` type for easier transition to the new API.
This should probably be removed at a later point, though.

As the `walkdir::WalkDir` type is not as nice as it could be, iterators
for two collections in the store could be built like this (untested):

    store
        .entries()?
        .in_collection("foo")
        .chain(store.entries()?.in_collection("bar"))

Functionality to exclude subdirectories is not possible with the current
`walkdir::WalkDir` implementation and has to be done during iteration,
with filtering (as usual).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-09-27 12:19:18 +02:00
Matthias Beyer 22d63f0946 Add functionality to create entry at a certain time 2018-07-20 01:37:36 +02:00
Matthias Beyer 664edc7943 Update version string: 0.8.0 -> 0.9.0 2018-05-09 11:39:33 +02:00
Matthias Beyer 2f0a557068 Fix for passing Arc<_> to store interface instead of Box<_> 2018-05-01 21:08:57 +02:00
Matthias Beyer 40688a3c2d Refactor libimagwiki to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 715753ed25 Refactor libimagtodo to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 72c83ae3f7 Refactor libimagtimetrack to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 08114bbf36 Refactor libimagnotes to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer e643f36fa3 Refactor libimaghabit to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer bf0bef058d Refactor libimagdiary to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer 8f03b4a71a Refactor libimagcontact to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer b3cf96d88b Refactor error handling, use more error chaining 2018-04-30 17:29:27 +02:00
Matthias Beyer 6d21d8eb49 Update dependency: filters: 0.2 -> 0.3 2018-04-29 10:46:36 +02:00
Matthias Beyer 5f3b7b31e7 Add support for storing email properties
We have to move the `Email` type at the bottom of the DeserVcard type
because it contains a table and we must emit tables as last values when
de/serializing.

Maybe this will shoot us in the foot later, but only with TOML I guess.
We'll see. For now, this is good.

For that we need to update a dependency: vobject -> 0.5
2018-04-27 16:57:37 +02:00
Matthias Beyer 0bacfb0a88
Merge pull request #1446 from matthiasbeyer/travis-clippy
Travis: clippy
2018-04-26 10:25:45 +02:00
Matthias Beyer ea80a5a09b Derive Default for InMemoryFileAbstraction, remove constructor 2018-04-25 19:15:07 +02:00
Matthias Beyer 80c07171aa Make sure we can deserialize
Use default values when field is not there when we deserialize. This
does automatically the right thing.
2018-04-25 13:45:00 +02:00
Matthias Beyer 56c1b78d93 Add getters for DeserVcard helper type 2018-04-25 13:45:00 +02:00
Matthias Beyer abc142f4b5 Rewrite library
libimagcontact stores all contact information in the entry header now.
2018-04-25 12:54:01 +02:00
Matthias Beyer 3eab3af7b0 Remove all libimagentryref usage 2018-04-25 11:30:42 +02:00
Matthias Beyer 55d9b5456f Adapt to new libimagentryview interface
And properly implement Viewer for DiaryViewer
2018-04-24 16:46:15 +02:00
Matthias Beyer 5666ef12d0 Rewrite to not use Store::retrieve_for_module() 2018-04-24 14:01:40 +02:00
Matthias Beyer 2c52957b63 Replace call to retrieve_for_module() with entries()
The iterator type handles everything else.
2018-04-24 13:40:42 +02:00
Matthias Beyer 22fb26dc12 Replace Store::retrieve_for_module() with own iterator type 2018-04-24 13:40:42 +02:00
Matthias Beyer 255f4211c9 Rewrite use of iterator with own iterator implementation 2018-04-24 13:40:42 +02:00
Matthias Beyer 9303a72a28
Merge pull request #1436 from matthiasbeyer/imag-log/show-ordered
Fix: imag-log show should order by datetime
2018-04-22 15:55:25 +02:00
Matthias Beyer ee75d2309c Fix: imag-log show should order by datetime 2018-04-22 14:33:53 +02:00
Matthias Beyer 86b60295ee Fix: get_youngest_entry_id()
We need to reverse the iterator for getting the _youngest_ entry here.

Also seems to fix the issue that imag-diary edit -d <date> did not work
properly.
2018-04-22 14:11:19 +02:00
Matthias Beyer d2dceb6640 Update version numbers: 0.7.0 -> 0.8.0 2018-04-19 10:05:53 +02:00
Matthias Beyer 4568b1f625
Merge pull request #1380 from matthiasbeyer/minor
Minor patches
2018-04-18 16:46:41 +02:00
Matthias Beyer 9daf2cae86 Update dependency: task-hookrs: master -> 0.5 2018-04-18 14:59:26 +02:00
Matthias Beyer adede7bf26 Remove notion of "main page" 2018-04-18 14:32:23 +02:00
Matthias Beyer 6f16924514 Remove functionality to delete whole wiki 2018-04-18 14:32:09 +02:00