Commit graph

617 commits

Author SHA1 Message Date
eb20a9d881
Merge pull request #1477 from matthiasbeyer/libimagstore/remove-walk
Remove Store::walk()
2018-05-02 18:39:11 +02:00
258d9f90d3 Remove Store::walk()
This patch removes the Store::walk() interface.

It was cumbersome and unused anyways.
2018-05-02 17:46:45 +02:00
888b31377e Fix: Do not check whether path exists - check whether its a file
This fixes a bug introduced in 195d921218
where we didn't check whether the path is actually a file.
2018-05-02 14:04:59 +02:00
2bf09e7737 Only create directory if it does not exist 2018-05-01 22:29:46 +02:00
84f426297e Add debug output 2018-05-01 22:29:46 +02:00
b27b392f4b Add trace output 2018-05-01 22:29:46 +02:00
972327e35e Remove Store::reset_backend() 2018-05-01 21:09:51 +02:00
2f0a557068 Fix for passing Arc<_> to store interface instead of Box<_> 2018-05-01 21:08:57 +02:00
42e2f18fb3 Pass around Arc<FileAbstraction> internally
Because the iterators need to be able to check whether the file exists
_in the backend_ (not on disk, but in the backend, because of in-memory
test for example), we need to be able to pass the backend to the
iterator intermediate type.

This patch implements this. It does so by changing the internal backend
member of the store from `Box<FileAbstraction>` to
`Arc<FileAbstraction>`, which gives us the ability to clone the
reference to the backend easily without needing to rely on lifetimes
here, because of the Arc.

Also, less boxes are always good.
2018-05-01 21:08:57 +02:00
d08c27e623 Rewrite StoreIdIterator extensions
This patch reimplements the iterator extensions.

As we iterate (in StoreIdIterator) over Result<StoreId> now anyways, we
don't need the extensions for Result iterators anymore.

This patch rewrites the extensions to be more simple in every way and
generic over the error type in the iterator.
All the errors have to do is implement From<StoreError>, which is what
they do when linking the generated error types with error_chain to the
libimagstore error types.
2018-05-01 17:44:01 +02:00
6ee3f4a3f6 Refactor libimagentrycategory to fit new store iterator interface 2018-05-01 17:44:01 +02:00
6f81d02445 Refactor libimagentryannotation to fit new store iterator interface 2018-05-01 17:44:01 +02:00
40688a3c2d Refactor libimagwiki to fit new store iterator interface 2018-05-01 17:44:01 +02:00
715753ed25 Refactor libimagtodo to fit new store iterator interface 2018-05-01 17:44:01 +02:00
72c83ae3f7 Refactor libimagtimetrack to fit new store iterator interface 2018-05-01 17:44:01 +02:00
08114bbf36 Refactor libimagnotes to fit new store iterator interface 2018-05-01 17:44:00 +02:00
e643f36fa3 Refactor libimaghabit to fit new store iterator interface 2018-05-01 17:44:00 +02:00
bf0bef058d Refactor libimagdiary to fit new store iterator interface 2018-05-01 17:44:00 +02:00
8f03b4a71a Refactor libimagcontact to fit new store iterator interface 2018-05-01 17:44:00 +02:00
a2ff298e67 Rewrite Store::entries()
This patch rewrites the Store::entries() function to not be collecting
the iterator.

It therefore introduces a new, internal, iterator type which creates the
StoreId objects from the pathes the PathIterator yields internally.

With this patch, the Store iterator interface changes, as the iterators
now yield `Result<StoreId, StoreError>` instead of `StoreId`.
This is necessary, as the internal conversion errors shouldn't be
hidden.

Of course, the iterator types (like the StoreGetIterator and so on)
should hold a Result<StoreId> internally as well, and also yield
appropritely. This was changed in this commit, too.
2018-05-01 17:44:00 +02:00
f4556f3983 Rewrite backend to not collect on pathes_recursively() 2018-05-01 17:44:00 +02:00
900d9f0984
Merge pull request #1474 from matthiasbeyer/libimagstore/cache-flush
Add functionality to flush the internal cache
2018-04-30 21:07:37 +02:00
41615bcc97
Merge pull request #1473 from matthiasbeyer/libimagstore/more-error-information
Add information about which storeid is the cause of the error in errors
2018-04-30 21:07:02 +02:00
6a5bcb2709 Remove unused error kinds 2018-04-30 18:54:11 +02:00
6a40ac6b98 Add information about which storeid is the cause of the error in errors 2018-04-30 18:53:54 +02:00
860e47a256 Add functionality to flush the internal cache
Before we had the problem that when iterating over _a lot_ (like 5k)
entries and also fetching them, at some point the OS would return with
"Too many files open".

That is because the store internally caches a lot.

With this change, the Store gets an API to query how big the cache is,
how much the cache can currently hold and (and that's the main thing in
this patch) to flush the cache to disk.

A function to simply ask the store whether its cache should be flushed
(which would us require to ask the OS how many files we can open...
which would be possible with `libc::getrlimit`) does not yet exist,
though, but could be added easily if desired.
2018-04-30 18:39:59 +02:00
b3cf96d88b Refactor error handling, use more error chaining 2018-04-30 17:29:27 +02:00
fc92cfc36f Move header filters to FailableFilter 2018-04-29 11:43:32 +02:00
30ac77d626 Add error module 2018-04-29 11:43:32 +02:00
e08ec34893 Remove empty module 2018-04-29 11:43:32 +02:00
6d21d8eb49 Update dependency: filters: 0.2 -> 0.3 2018-04-29 10:46:36 +02:00
0976cab014
Merge pull request #1464 from matthiasbeyer/libimagentrygps/32-bit-gps-values
libimagentrygps: 32 bit gps values
2018-04-29 00:35:21 +02:00
93c3bb5862 Upgrade variables to 64 bit 2018-04-28 23:27:12 +02:00
5870fa0785 Fix: Use 16 bit variables for GPS degree/minute/second 2018-04-28 23:18:02 +02:00
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
82867f3ff6 Fix tests for new interface 2018-04-27 13:24:59 +02:00
f0969db47c Rewrite
This patch rewrites the whole libimagcategory and brings it to a nice
standard (the code before was rather messy).

Now, categories are represented by an entry in the store and all entries
which have this category are linked to that entry.
2018-04-26 12:05:28 +02:00
9fc9e7fe17 Outsource iterator in iter module 2018-04-26 12:05:28 +02:00
ab15d89e64 Rewrite CategoryRegister as CategoryStore 2018-04-26 12:05:28 +02:00
5f305ef7a7 Add module for category handling 2018-04-26 12:05:28 +02:00
c26f1aae2a This module should be named "entry" 2018-04-26 11:20:40 +02:00
f321aa82a1 Make sure category is linked when setting it 2018-04-26 11:20:09 +02:00
0bacfb0a88
Merge pull request #1446 from matthiasbeyer/travis-clippy
Travis: clippy
2018-04-26 10:25:45 +02:00
ea80a5a09b Derive Default for InMemoryFileAbstraction, remove constructor 2018-04-25 19:15:07 +02:00
6a34e7a8fd Derive Default for FSFileAbstraction, reduces boilerplate 2018-04-25 19:15:07 +02:00
bf363c4748 Use "if let" if matching on a single pattern 2018-04-25 19:15:07 +02:00
f1142c414d Use ok_or_else() instead of ok_or() 2018-04-25 19:15:07 +02:00
22170a0d55 Do not String::from(String) 2018-04-25 19:13:51 +02:00
6f5590713a Use single quotes here 2018-04-25 19:13:51 +02:00
44521a7c8c Dont use "return" keyword at end of function 2018-04-25 19:13:51 +02:00