Commit graph

44 commits

Author SHA1 Message Date
bir
0041497d23 Ensure events are not missed
Have indexer apply updates before batch is completed
to ensure that we have an up-to-date index (or we will
if updating fails and we retry).

Rename CustomCacheHandler's methods to avoid confusion.

Close #8902

Co-authored-by: paw <paw-hub@users.noreply.github.com>
2025-06-04 10:36:46 +02:00
hrb-hub
a98731577b Small OfflineStorageTest refactor
- Removes "test" from o.spec
- Changes o( to o.check
2025-06-04 10:36:46 +02:00
hrb-hub
83ca9e0bf7 Ensure MailOfflineCleaner only cleans Trash and Spam once old
Previously MailOfflineCleaner would clean Trash and Spam folders
everytime. This was done under the assumption that Trash and Spam were
excluded from search, which wasn't the case, meaning that they had to be
re-indexed and re-retrieved on every login.

Since we decided to keep Trash and Spam included in search, Trash and
Spam are now cleaned same as all other folders.

Close #8837

Co-authored-by: paw <paw-hub@users.noreply.github.com>
2025-06-04 10:36:46 +02:00
wrd
90e5a239d9 Use date instead of number for OfflineTimeRange, connect to search
Search extends range on login based on the OfflineTimeRangeDate

Extending search range extends OfflineTimeRangeDate

Co-authored-by: ivk <ivk@tutao.de>

Close #8549
2025-06-04 10:36:46 +02:00
ivk
86d5775e16 Add SQLite search on clients where offline storage is available
- Introduce a separate Indexer for SQLite using FTS5
- Split search backends and use the right one based on client (IndexedDB
  for Browser, and OfflineStorage everywhere else)
- Split SearchFacade into two implementations
- Adds a table for storing unindexed metadata for mails
- Escape special character for SQLite search
  To escape special characters from fts5 syntax. However, simply
  surrounding each token in quotes is sufficient to do this.
  See section 3.1 "FTS5 Strings" here: https://www.sqlite.org/fts5.html
  which states that a string may be specified by surrounding it in
  quotes, and that special string requirements only exist for strings
  that are not in quotes.
- Add EncryptedDbWrapper
- Simplify out of sync logic in IndexedDbIndexer
- Fix deadlock when initializing IndexedDbIndexer
- Cleanup indexedDb index when migrating to offline storage index
- Pass contactSuggestionFacade to IndexedDbSearchFacade
    The only suggestion facade used by IndexedDbSearchFacade was the
    contact suggestion facade. So we made it clearer.
- Remove IndexerCore stats
- Split custom cache handlers into separate files
  We were already doing this with user, so we should do this with the
  other entity types.

- Rewrite IndexedDb tests
- Add OfflineStorage indexer tests
- Add custom cache handlers tests to OfflineStorageTest
- Add tests for custom cache handlers with ephemeral storage
- Use dbStub instead of dbMock in IndexedDbIndexerTest
- Replace spy with testdouble in IndexedDbIndexerTest

Close #8550

Co-authored-by: ivk <ivk@tutao.de>
Co-authored-by: paw <paw-hub@users.noreply.github.com>
Co-authored-by: wrd <wrd@tutao.de>
Co-authored-by: bir <bir@tutao.de>
Co-authored-by: hrb-hub <hrb-hub@users.noreply.github.com>
2025-06-04 10:36:46 +02:00
map
d72308a8f0 Revert "ensure range is not updated beyond a cutoff id when setting lower range"
This reverts commit 9b5a1be9

We ran into an issue where indexing ended up in a loop.
2025-06-02 14:26:23 +02:00
ivk
9e31ee0409 Inject type model resolvers
Passing instances explicitly avoids the situations where some of them
might not be initialized.

We also simplified the entity handling by converting entity updates to
data with resolved types early so that the listening code doesn't have
to deal with it.

We did fix some of the bad test practices, e.g. setting/restoring env
incorrectly. This matters now because accessors for type model
initializers check env.mode.

Co-authored-by: paw <paw-hub@users.noreply.github.com>
2025-05-27 14:52:44 +02:00
abp
9b5a1be911 ensure range is not updated beyond a cutoff id when setting lower range
As we prevent inconsistencies between the data which might be deleted
by the offline cleaner and the range database, we can safely remove
locks.

Co-authored-by: map <mpfau@users.noreply.github.com>
2025-05-27 14:37:09 +02:00
ivk
37f00a720f Add MailBag cleanup to MailOfflineCleaner, fix tests
Switches OfflineStorageTest to use in-memory DB, it is faster and less
likely to break (e.g. if DB is corrupted or already exists).

Gets rid of some redundant init() calls that were breaking the db state.

Fixes some assumptions about mails not being deleted.
2025-05-15 11:36:46 +02:00
mac-github
279278179b store ServerModelParsedInstances in offline db
Co-authored-by: nig <nig@tutao.de>
Co-authored-by: abp <abp@tutao.de>
Co-authored-by: jhm <17314077+jomapp@users.noreply.github.com>
Co-authored-by: das <das@tutao.de>
2025-05-06 18:45:27 +02:00
Kinan
edbf281b88
switch to typeIds and attrIds, add SystemMV126, TutanotaMV86, BaseMV2
Refactor our instance deserialization/serialization pipeline, both on
TypeScript and on Rust [sdk] to use typeId and attributeIds instead of
typeNames and attributeNames. We furthermore ignore cardinalities
on associations until the instance layer and always
store associations as arrays. This commit introduces **eventual
consistency** on the client, i.e. we are from now on always storing data
in the newest schema format (activeApplicationVersionsForWritingSum)
which ensures that all data is already available on the client after
updating the client to a newer version. This removes the need for
offline migrations on the client and also removes backward migrations
on the server. Furthermore, the server model types are now available
on the client, retrievable through the ApplicationTypesFacade. This is
our first step towards FastSync.

Co-authored-by: nig <nig@tutao.de>
Co-authored-by: abp <abp@tutao.de>
Co-authored-by: jomapp <17314077+jomapp@users.noreply.github.com>
Co-authored-by: map <mpfau@users.noreply.github.com>
Co-authored-by: sug <sug@tutao.de>
Co-authored-by: Kinan <104761667+kibibytium@users.noreply.github.com>
2025-04-28 12:44:35 +02:00
jhm
6143c4336b
fix mails disappearing from folders on desktop and mobile
When deleting mails MailOfflineCleaner from the OfflineStorage
based on the cutoffId, we were comparing a base64Url encoded customId
of an MailSetEntry with a base64Ext encoded customId cutoffId when
updating the range for the list in OfflineStorage#updateRangeForList.
This lead to wrong ranges for MailSetEntries in the ranges db for
folders with less than 100 mails newer than cutoffId in it.

This commit fixes the comparison, ensuring we compare base64Url.
Furthermore, in order to fix already broken ranges, we modify set lower
range to the cutoffId, in case there are no entities (id == null)
with a lower range currently set to CUSTOM_MIN_ID.

Co-authored-by: abp <abp@tutao.de>
2025-02-19 12:30:38 +01:00
abp
84d4c125f0
remove legacy MailFolders and add TutanotaModelV83
Co-authored-by: jhm <17314077+jomapp@users.noreply.github.com>
2025-02-11 16:53:52 +01:00
ivk
2ed48135a8
Replace esbuild with Rolldown
- switch desktop build to esm
 - convert mithril to esm
 - run worker as esm module
 - fix dependency from DesktopAlarmScheduler to calendar app
 - switch napi-rs cli to 3.0
 - fix mimimi imports
 - remove hacky method on generated dispatcher
 - refactor native rollup plugins

 Co-authored-by: bir <bir@tutao.de>
2025-01-13 10:05:18 +01:00
paw
8c1ed56072
update eslint to v9
Co-authored-by: paw-hub <paw-hub@users.noreply.github.com>
2025-01-09 14:55:11 +01:00
wrd
f99bd69ff0 Move indexer and mail search to mail-app 2024-09-23 16:49:37 +02:00
sug
dfe1dddb95 improve mail set migration performance
to avoid excessive entity updates and inconsistent offline storages,
we don't send entity updates for each mail set migrated mail.
instead we detect the mail set migration for each folder and drop
its whole mail list from the offline cache.

we could fix up the database when we receive the changed folder,
but that would involve re-doing the migration locally and will
lead to very long entity event handling that might get interrupted,
breaking the offline database anyway.
2024-09-09 15:54:04 +02:00
map
b0dd4225e3 delete MailSetEntries from the offline database in clearExcludedData #7429
additionally, add test for storing instance with CustomId OfflineStorage
2024-08-27 17:16:27 +02:00
map
2d24bab6f9 MailSet support (static mail listIds)
In order to allow importing of mails we replace legacy MailFolders
(non-static mail listIds) with new MailSets (static mail listIds).
From now on, mails have static mail listIds and static mail elementIds.
To move mails between new MailSets we introduce MailSetEntries
("entries" property on a MailSet), which are index entries sorted by
the received date of the referenced mails (customId). This commit adds
support for new MailSets, while still supporting legacy MailFolders
(mail lists) to support migrating gradually.

* TutanotaModelV74 adds:
  * MailSet support
  * and defaultAlarmList on GroupSettings

* SystemModelV107 adds model changes for counter (unread mails) updates

* Adapt mail list to show MailSet and legacy mails
  The list model is now largely unaware about listIds since it can
  display mails from multiple MailBags. MailBags are static mailLists
  from which a mail is only removed from when the mail is permanently
  deleted.

* Adapt offline storage for mail sets
  Offline storage gained the ability to provide cached entities
  from a list of ids.
2024-08-20 16:19:58 +02:00
wrd
8ab3b14edd Move files to new folder structure
Co-authored-by: @rih-tutao
2024-07-26 16:42:13 +02:00
jhm
b6ad11e33a Remove LegacyMailWrapper (legacy mail bodies) and cleanup TutanotaModel
Prior to starting implementing static MailIds and MailSets, we
want to clean up the current TutanotaModel. Therefore, this commit
removes a lot of legacy metamodel definitions that are not used any
longer, including removing the LegacyMailWrapper (legacy mail bodies).

Additionally, this commit inter alia includes:
* removing types no longer needed after migrating to MailDetails, e.g.
  the "body", "toRecipients", "ccRecipients", "bccRecipients",
  "replyTos", "sentDate" and "headers" references / values from MAIL_TYPE
* removing "mails" reference form MAIL_BOX_TYPE
* removing "subFolders" reference from MAIL_FOLDER
* removing the legacy types MAIL_BODY_TYPE and MAIL_HEADERS
* removing Value.OLD_OWNER_GROUP_NAME, and Value.OLD_AREA_ID_NAME from
  FILE_TYPE and CONTACT_TYPE

Closes #7255

Co-authored-by: sug <sug@tutao.de>
2024-07-26 16:03:01 +02:00
ivk
ad83f751b2 Extended notification preview, change credential encryption
Implemented extended notifications which include the sender.

Re-implemented credential encryption and storage, moved credential
data to the native storage, changed credential encryption on mobile to
always be device lock + implement app lock independently of encryption.

Re-implemented SSE on desktop in a more modular way.

Re-organized iOS app to share the code between the main app code and
app extensions.

Close #6608

Co-authored-by: wec43 <wec@tutao.de>
2024-05-22 14:10:08 +00:00
vis
16a5590760 Disallow Partial instance initializers
Co-authored-by: @paw-hub, @mpfau, @vaf-hub
tutanota#6118
2023-12-12 18:52:44 +01:00
vis
af9d0e668c Enforce providing initializer when creating instances
Thanks @charlag for the solution for tests!

tutanota#6118
2023-12-12 18:52:44 +01:00
nig
e57b9c7ff2 threaded sqlcipher
#5112
2023-09-22 12:09:18 +02:00
ivk
ada89d6fc2 Switch to @tutao/otest from ospec 2023-07-28 16:08:22 +02:00
nig
978d9780c2 fix linter errors for missing node: protocol
close #4367
2023-05-05 11:29:09 +02:00
nig
87a7c83d17 fix updated clients caching backported events with missing exclusions
fix #5320
2023-03-30 10:03:20 +02:00
vaf
1919cee2f5 add referral link setting and news item, see server issue 1349, 1350, 1351 2023-03-22 09:14:11 +00:00
wrd
d6ada95fc4 fix broken test 2023-01-20 10:26:06 +01:00
wrd
e72305eb3f Add ability to move folders
close #4858
2023-01-20 10:26:06 +01:00
map
b29a7b319a add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2023-01-12 11:41:40 +01:00
ivk
50b23ebd1b Run prettier on the whole project 2022-12-27 16:08:23 +01:00
nig
0e62cedf88 [refactor] split GroupViewer into view and model 2022-12-19 17:43:47 +01:00
jhm
11b475c7ff Move vaccumDb, closeDb call to iOS ViewController 2022-12-13 16:59:26 +01:00
jhm
e3304f2fbe Create new test for ranges db lock and fix tests 2022-12-13 16:59:26 +01:00
jhm
2203374313 Lock "ranges" database write/read access
We want to lock the access to the "ranges" database when
writing/reading in order to prevent race conditions.
2022-12-13 16:59:26 +01:00
jhm
79abde10d1 Offline storage clearExcludedData after login and activate incremental_vacuum
To improve login performance, we want to clear excluded data
(i.e. trash and spam lists, old data) from the offline storage after the login.

We also want to activate "auto_vacuum = incremental" for the offline storage database
in order to allow for faster vacuum execution and run "incremental_vacuum" before
the database is closed.

Fixes #4723
2022-12-13 16:59:26 +01:00
ivk
b3588fe079 Remove entities when the owner group membership is lost
Add ownerGroup column to offline db.

We detect the relationship change by the update of the user. We track
current user in cache storage because it already was receiving it in
case of offline storage and storage already had appropriate lifecycle
for it.

We empty the tables instead of migrating them because we want to remove
them anyway due to corruption (see #4664)

fix #2874
2022-10-27 15:50:33 +02:00
nig
22efb3f46b [desktop] move SQL from node process to web app
close #4293
2022-08-18 15:12:05 +02:00
nig
9bc1c40be3 [desktop] Fix multiple issues with offline database deletion
fix #4344

When the database file was corrupted or got out of sync with the key
then it wasn't handled in any way, we would just fall back to the
ephemeral cache.

Now we delete the database and create it again, there's nothing else
we can do.

fix #4382

When adding another account that would override existing stored
credential we would generate a new database key but we would try to
use it with the old database.

Now instead we are forcing the creation of new database and delete
the old one directly from the worker.
2022-07-21 15:25:38 +02:00
jom
1748142a0a Consolidate naming of credentials handling interfaces
#4210
2022-07-21 14:10:37 +02:00
nig
0f1314d186
[refactor] move getTypeId from OfflineStorage to TypeRef 2022-05-25 17:04:21 +02:00
jom
ca177b74f5
Add framework for migrating offline database
When there is a model change on the server that would conflict with
the entities stored in the offline database, we need to do a migration
We generate some model diffs with the code generator and use them
for a compile-time check.

Co-authored-by: ivk <ivk@tutao.de>
2022-05-25 16:30:34 +02:00
Renamed from test/tests/api/worker/rest/OfflineStorageTest.ts (Browse further)