且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

评估与Dropbox同步核心数据的策略

更新时间:2023-02-17 09:55:43


这种安排是否非常低效,应该完全避免?

A. Is this arrangement hugely inefficient, to the extent where it should be completely avoided? What if we can guarantee the database is not large in size?

不相关,因为:


B。这种安排是否有助于文件损坏?超过同步通过deltas / changelogs?如果是,请您详细解释为什么?

B. Is this arrangement conducive to file corruption? More than syncing via deltas/changelogs? If so, will you please explain in detail why?

是的,非常非常。几乎保证。我建议您查看如何破坏SQLite数据库文件。你可能会提交第1节中描述的至少两个问题,包括在事务处于活动状态时复制文件,并删除(或无法复制或无用的副本)日志文件。在任何严重的测试中,您的方案很可能立即崩溃。

Yes, very much so. Virtually guaranteed. I suggest reviewing How to Corrupt An SQLite Database File. Offhand you're likely to commit at least two of the problems described in section 1, including copying the file while a transaction is active and deleting (or failing to copy, or making a useless copy of) the journal file(s). In any serious testing, your scheme is likely to fall apart almost immediately.

如果这还不够,请考虑两个设备同时保存更改的情况。然后怎样呢?如果你幸运,你只会得到一个Dropbox的臭名昭着的冲突的副本的文件的副本,只意味着丢失一些数据。

If that's not bad enough, consider the scenario where two devices save changes simultaneously. What then? If you're lucky you'll just get one of Dropbox's notorious "conflicted copy" duplicates of the file, which "only" means losing some data. If not, you're into full database corruption again.

当然,拆除Core Data栈以进行同步对用户来说是一个巨大的不便。

And of course, tearing down the Core Data stack to sync is an enormous inconvenience to the user.

如果您想考虑通过Dropbox同步Core Data,我建议使用以下方法之一:

If you'd like to consider syncing Core Data via Dropbox I suggest one of the following:


  1. Ensembles ,可以同步Dropbox(同时避免上述问题)或iCloud(同时避免问题iOS内置的Core Data / iCloud同步)。

  2. TICoreDataSync ,它使用Dropbox文件同步,但避免在文件存储中放置SQLite文件。

  3. ParcelKit ,它使用Dropbox的新数据存储API。 (请注意,这是相当新的,数据存储API本身仍然是测试版)。

  1. Ensembles, which can sync over Dropbox (while avoiding the problems described above) or iCloud (while avoiding the problems of iOS's built-in Core Data/iCloud sync).
  2. TICoreDataSync, which uses Dropbox file sync but which avoids putting a SQLite file in the file store.
  3. ParcelKit, which uses Dropbox's new data store API. (Note that this is quite new and that the data store API itself is still beta).