Commit graph

13 commits

Author SHA1 Message Date
ivk
2e93b24af2
Improve how models are generated
The idea is to reduce number of separate files and imports for them to
make it easier on compiler. Unfortunately so far the gains are not as
big as we hoped but this change can be a base towards reducing direct
dependency on typeModels to that we can avoid recompiling them.
Because of that we try to avoid importing them directly and
theoretically we could reduce it even more.
2022-04-25 15:50:51 +02:00
jom
6d7cfc0cd3
Handle out of sync offline database
Upon logging in and also when reconnecting, if it is detected that the stored offline data is out of sync with the servers (i.e. We haven't connected for > 45 days, meaning we would most likely have missed some entity events), then we just delete the stored offline data. Directly refreshing the offline cache is not taken care of with this commit, and we may or may not decide to do that in the future
2022-04-22 18:42:03 +02:00
jom
9009a57f8e Encrypt offline database using sqlcipher, #3816
The database key is stored and encrypted alongside the user's stored credentials

we depend on our own fork of Signal's fork of better-sqlite3 which replaces sqlite3 with sqlcipher. Our fork was necessary in order to obtain the newest version of better-sqlite-3. This fork also has a modification that makes it not try to resolve the nativeBindingPath into an absolute path, because otherwise it was not possible to make it load the native module from within the bundled app

In Desktop, we don't know what kind of storage to use until the use is logging in, so we want to delay initialisation until then by using a proxy storage implementation. The loginfacade may not use the cache in this case.
2022-03-17 14:44:14 +01:00
ivk
d572734d87 Fix initializing cache with batch ids for the first time
For each group we record the last batch we processed so that we can
download events since that batch and update the cache. Unfortunately
we would only write those ids when some events are processed. In case
there are no events we would not download any batches on next login.

This fixes plugs the issue with this case by preemptively writing last
id if none could be loaded. Next time we will download batches starting
with that id.
2022-03-09 14:20:20 +01:00
ivk
b2a01f5164 Fix OutOfSync for persistent cache
The time when the entityEvents were downloaded last time was used
incorrectly. Because of how it was written and read it would always be
the same number, and we would never detect OutOfSync.

Now we moved it completely to the cache, and we rely on cache to keep
track of it. We do not write incorrect value before fetching the
events during initialization anymore.
2022-03-09 14:20:20 +01:00
jom
94bc6b3e31 specify minimum chunk size when extending a cache range
this is to avoid that we might make lots of small requests unintentionally

This commit also contains some refactoring and cleanup
2022-02-28 16:44:17 +01:00
jom
50c41f3075 Refactor EntityRestCache loadRange, fix loading towards ranges, fixes #3928
It was written recursively due to having been originally written with promise chains, which made it difficult to understand/test/debug

The implementation of "loading in the direction of an existing range" was also incorrect. It would only extend in one direction.
We fixed this and added a test case
2022-02-28 16:44:17 +01:00
sas
e366498704 Disable persistent cache, fix #3880 2022-02-15 09:54:54 +01:00
sas
7cb4828c56 Introduce persistent cache for desktop, close #3823 2022-02-15 09:54:54 +01:00
ivk
253441b9ac Convert codebase to Typescript, close #3746 close #3594
Co-authored-by: jom <jom@tutao.de>
Co-authored-by: thp <thp@tutao.de>
Co-authored-by: vis <vis@tutao.de>
2022-01-07 16:21:07 +01:00
jom
105a352746 WIP fix typescript errors in source 2022-01-07 16:21:07 +01:00
jom
06bf683733 WIP convert flow to typescript 2022-01-07 16:21:07 +01:00
jom
e6ae500bb6 Rename .js -> .ts 2022-01-07 16:21:07 +01:00
Renamed from src/api/worker/rest/EntityRestCache.js (Browse further)