Commit graph

13 commits

Author SHA1 Message Date
6b6b7d145e [ios] fix icloud initial sync bug when some files are not downloaded at start
https://github.com/organicmaps/organicmaps/issues/10221
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2025-02-11 09:27:15 +00:00
9c8b6d934c [ios] start downloading icloud item with coordination
Attempt to fix the https://github.com/organicmaps/organicmaps/issues/10042

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2025-02-11 09:25:51 +00:00
79b4826859 [ios] [icloud] skip file recreaion during the update event from the icloud
When the user deletes the file locally with the enabled icloud happens this:
1. the file is moved to the local .Trash dir
2. the LocalDirectoryMonitor send event to delete the file from the iCloud
3. the SynchronizationFileWriter trash the remote file using the system API `try fileManager.trashItem`
4. the file is moved to the devices trash
5. the icloud sends the update to the metadataQery's `queryDidUpdate` with the updated state. This update is tricky - it calls the method twice: on the first call the deleted file appears in the updated list (`userInfo[NSMetadataQueryUpdateChangedItemsKey]`) and on the second call the deleted file appears in the deleted list (`userInfo[NSMetadataQueryUpdateRemovedItemsKey]`). There is no way to disable this behaviour.
At that point the bug can happens: the 1st `update` (that contains the file in the deleted list) call can triggers the file recreation because the synchroisztion starts to process the event and make an attempt to recreate the file but it is already deleted.

The fix is: skip missed file during the `Update` event. The case when the missed file is in the updated in undefined and should be skipped by checking the file existence.

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2025-01-16 22:58:28 +04:00
4fdcd380c7 [ios] improve icloud sync logging
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-11-11 21:06:39 -03:00
432ec309f6 [ios] refactor icloud synchronization
1. remove the iCLoud's .Trash dir scanning because on ios this feature is blocked. This is why the `isRemoved` property was removed from the `MitadataItem`
2. runtime monitors sends only the added/updated/deleted items lists on didUpdate and the whole content on didFinishGathering
3. because of 1, when icloud is running - it is source of truth.
During the initial phase (1st enabling of enabling after disabling) all the data from the cloud and local dir will be preserved.
4. simplified the state manager's logic
5. improved logs
6. fixed test

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-11-06 11:54:17 -03:00
714136e249 [ios] fix the icloud trashing bug
When the file doesn't exist in the icloud dir and the manager attemps to move this file into the trash the exception is thrown and the sync is stopped. This issue was fixed by the additional file existence check.

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-08-25 12:10:45 +02:00
18bed8dde9 [ios] add more logs to the icloud sync
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-08-02 19:33:17 +02:00
0e8fb07037 [ios] update the file content using the safereplace
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>

# Conflicts:
#	iphone/Maps/Core/iCloud/SynchronizationFileWriter.swift
2024-08-02 19:26:11 +02:00
ab538bb551 [ios] refactor icloud sync to prevent syncing when some errors occur
- throws an exeption when the metadata cannot be initialized from the url or nsmetadataitem
- add 2 new sync errors cases to clarify errors reasons
- stop sync on the all errors except ubiquity errors (uploading/downloading)
- subscribe the settings screen on the sync state notification to update the relates cell properly from the cloud manager
- show the alert with an error if cloud sync fails with proposal to the user to send a bugreport

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-07-29 18:38:57 +02:00
03d41edb29 [ios] remove unused code from the MetadataItem
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-07-29 18:38:57 +02:00
Alexander Borsuk
a39eed5805 [xcode] Fixed warnings for Xcode 16
- Use C17 instead of C11
- Clean up some settings

Signed-off-by: Alexander Borsuk <me@alex.bio>
2024-07-05 13:06:51 +02:00
577c6cc37f [ios] add DocumentPicker and FileType
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-06-17 09:49:09 +02:00
9a4fdfc1a6 [ios] default implementation of the iCloud sync feature
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
2024-05-30 10:15:34 +03:00