Add metadatabase URL override for CloudKit sync#426
Add metadatabase URL override for CloudKit sync#426byMohamedali wants to merge 1 commit intopointfreeco:mainfrom
Conversation
|
Hi @byMohamedali, it's intended that the metadatabase is created right alongside wherever the user's database is. You can see that's done right here: sqlite-data/Sources/SQLiteData/CloudKit/SyncEngine.swift Lines 2139 to 2143 in 65502ac So I'm not sure why this would be needed. Are you positive that the metadatabase is always created in application support? |
|
Hi @byMohamedali, can you confirm my comments above? If we don't hear back we will go ahead and close this. |
|
Yes sorry for late answer, on tvOS we can use only this |
|
I was having the same issue on tvOS. Metadatabase connection:
|
|
Yes, so then it seems to me this is the problem: sqlite-data/Sources/SQLiteData/CloudKit/SyncEngine.swift Lines 2242 to 2245 in 65502ac We are actively creating the application support directory when establishing the metadatabase. I don't think that really needs to be there and may have just been left over from some other change. It seems we could just remove that to fix this. But either way, I would ask you to please investigate a better fix than what this PR does right now, because as far as I can tell it should not be necessary to customize where the metadatabase is saved. It is saved in the same directory as the user's database, and so as long as the user is saving their database is the correct place, the metadatbase should be fine. |
Summary
Adds an optional
metadatabaseURLoverride to SQLiteData's CloudKit APIs so callers can choose where the CloudKit metadata database lives.Changes
metadatabaseURL: URL? = nilto:SyncEngine.init(for:tables:privateTables:containerIdentifier:metadatabaseURL:defaultZone:startImmediately:delegate:logger:)Database.attachMetadatabase(containerIdentifier:metadatabaseURL:)Application Support.Motivation
Some platforms, notably tvOS, may not allow the current hardcoded
Application Supportbehavior for this metadata database. The main user database may already be configured to live somewhere else, but CloudKit setup still fails because the metadata store is not configurable.This change keeps the default behavior intact for existing apps while allowing callers to explicitly provide a writable location when needed.
Example