In my app I allow users to make a backup copy of their database from one 
device and restore it to another if they wish. My app just makes a zip file 
of the sqlite file and any file attachments. I'd like to do the same with 
Couchbase Lite. The user can make a backup file on iOS and restore to Mac 
or vice versa. I'd like to be able to keep that functionality.  There's a 
replaceUUIDs method on CBLDatabase that seems like it would be perfect for 
this scenario.  And I could always add a call to that method that the user 
can initiate if they were to do something like replace the database file in 
the Finder instead of from doing a restore within the app. If they have 
troubles with replication I can tell them to "reset sync" to clear that up.

Although what would happen on the server side if the client databases 
suddenly had different UUIDs? Does the server keep track of the UUIDs for 
each device? I would almost think not since a device might go offline 
permanently at some point. Then the server would be keeping track of a 
potentially non-existent database.


Thanks!

Brendan

On Wednesday, July 8, 2015 at 9:38:18 PM UTC-6, Jens Alfke wrote:
>
>
> On Jul 7, 2015, at 11:43 PM, Brendan Duddridge <[email protected] 
> <javascript:>> wrote:
>
> The NSDocument's setFileURL method will be called if the document is moved 
>> by another process, so I was going to override this and close the database 
>> and re-set the CBLManager's URL and re-open it with the new URL.
>
>
> That’s very prone to race conditions, since the method is called *after* the 
> document is moved. 
>
> This could be problematic even without a document based database. A user 
> could easily copy the same database file to multiple devices and then start 
> replication.
>
>
> It’s a lot less likely if the databases are invisibly housed in 
> Application Support.
>
> Does the replicator automatically detect this situation and automatically 
> start replication from scratch? That would be ok if it did I think. 
> Although I don't know if the replicator would set a new unique UUID for one 
> of the databases so maybe this will be constantly problematic.
>
>
> The replicator will reset, but it’ll happen whenever the ‘other’ copy of 
> the database was the last one to replicate with that server. The database 
> never changes its UUID.
>
> —Jens
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/977e5a5c-6bce-4c75-9720-bc7a790819a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to