Commit Graph

5890 Commits

Author SHA1 Message Date
Matthias Beyer 9af10fd2eb Fix indention
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:40 +01:00
Matthias Beyer 734112b856 Simplify
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:20 +01:00
Matthias Beyer d19020c3f5 Remove unnecessary Error::from() call
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:09 +01:00
Matthias Beyer 341e64998d Remove Iterator::size_hint() implementation
I'm not sure why the author added this in the first place, but I bet we
don't need this.

So remove code we do not need. Feel free to prove me wrong and revert
this patch.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-07 20:53:12 +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 d32f41aeab Outsource hashing itself so that we can re-use it
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:23:57 +01:00
Matthias Beyer b2fbf1e462 Add debug and trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 23:14:43 +01:00
Matthias Beyer 44896327e5 Merge branch 'rewrite-mail-code' into master
This merge includes the rewritten mail infrastructure. It was rewritten
for the new libimagentryref API, but might not be complete in regards
towards maildir handling.

Also, it only contains minimal features, not even bulk-import is
implemented yet.

Also, sending, receiving and other nice-to-have MUA features are not yet
implemented.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:23:19 +01:00
Matthias Beyer dfc02a5679 Move helper function to libimagentref::util
This moves the helper function for getting the `Config` object from the
configuration file via the runtime.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +01:00
Matthias Beyer a959167b15 Rewrite imag-mail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +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 198c59f717 Revert "Remove imag-mail"
This reverts commit f9a980c344.

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 27c0a30494 Add config fetching function for Ref::get_path() parameter
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:42 +01:00
Matthias Beyer 34d9f3429f Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:29 +01:00
Matthias Beyer 0a62548173 Add function to get relative file path
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:21 +01:00
Matthias Beyer 37bf2ce191 Fix: Use StoreIdWithBase::from_full_path
We iterate over full pathes to store entries here, which causes
`StoreId::new()` to error. But if we use the internal parsing helper
`StoreIdWithBase::from_full_path()` and then call `::into_storeid()` on
the resulting object, everything is fine.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 12:31:37 +01:00
Matthias Beyer ed862db76f Fix: Strip the prefix of the path
The previous implementation did not strip the prefix of the "relpath"
header value, which resulted in the whole path being in the header,
which is obviously wrong.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 12:31:37 +01:00
Matthias Beyer 04e006154c Fix: Use "ref.relpath" as path to header value
The header value for the relative path is at "ref.relpath". This fixes
the wrong selector.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
Matthias Beyer 22c239c212 Add output about logger settings in logging setup
This way we can get trace-level information about the logger itself when
it is generated. Because from time to time we might want to have a look
at that.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
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