Fat Cat Software

Don’t store your photo library on Dropbox

I see a lot of users of both PowerPhotos and iPhoto Library Manager who want to store their iPhoto/Photos library in Dropbox. This is totally understandable, as it would provide an easy way to keep your library synced between two Macs, and would be totally awesome… if it worked reliably. Unfortunately, the way the library is stored internally does not mesh well with how Dropbox’s syncing works, and can easily result in data corruption. Here’s how that can happen.  Photos uses a series of SQLite database files to store the data for the library. This includes thing like lists of all the photos in the library, all the metadata for those photos, how they’re organized into moments and albums, and so forth. Each SQLite database is essentially a single file (though a couple helper files are also used while the database is open) which contains however many hundreds or thousands of database records are required to store all the information for the library. When you make a change in your library, such as creating a new album, Photos will modify the database with the new data necessary for whatever changes you made. SQLite makes this process very efficient, only needing to modify a small portion of the file to add/modify the necessary data, rather than having to write out an entirely new copy of the database file for each individual change. Dropbox, on the other hand, performs all of its syncing on a per-file basis. So, when Photos make a small modification to one of its database files, Dropbox will copy the entire data file again. Here’s an easy way to demonstrate how this can cause data loss in your library, using two Macs, which we’ll call Mac A and Mac B. (everything here applies to iPhoto and Aperture libraries as well) On Mac A, create a new Photos library in your Dropbox folder, either by holding down the option key while launching Photos, or by using PowerPhotos to create the library. Import a bunch of photos into the library, just to give us a bit of content to work with. On Mac B, you should see the library appear in its Dropbox folder as Dropbox starts syncing the data across. Wait until the checkmark by the library turns green, indicating that Dropbox has finished syncing. Double click the library on Mac B to open it in Photos, which it will do happily, even though the library is still open on Mac A. You should see the same content you added to the library on Mac A. Create a new album in the library on Mac B, and name it “Album B”. Add a couple photos to it if you’d like. Over on Mac A, create an album in the library called “Album A”. Add a couple photos to it if you’d like. Quit Photos on both Macs, in any order. You should see a flurry of Dropbox syncing activity on both machines, which will eventually settle down as Dropbox finishes its syncing. Open the library back up on Mac A, and open the library back up on Mac B. You will most likely see either Album A show up on both machines, or Album B show up on both machines, but not both. This is because, while both Macs have modified their own local copy of the library database, Dropbox does not have the smarts to merge the bits of those files that have changed together (nor should it). One of the databases will overwrite the other one, blowing away whatever changes were made there. Which one survives and which one doesn’t will depend entirely on the timing of Dropbox’s syncing. If you’re less lucky, one or both of the libraries won’t be openable in Photos at all, which will display a message saying that it needs to repair the library database. Even if it successfully completes the repair, you will either only see one of your new albums in the resulting library, or perhaps neither of them. Now, it is theoretically possible to make a setup like this work, if you make sure not to open both libraries at once, and always remember to close Photos on one machine before using it on the other, and always remember to wait for Dropbox to completely finish syncing your files before opening the library, and Dropbox never has a hiccup or delay in copying one of those database files, and so on. Oh, and if you decide to use this library as your system and/or iCloud photo library, meaning the system always has the library open in the background? Fugetaboutit.This is actually more dangerous than an obvious immediate failure, because doing this can actually work OK, for a while at least. But you’re definitely playing with fire if you use this to sync your library on a long term basis. Apple could try to add some sort of lock file that might prevent simultaneous opening of a library on two machines, but that would still leave plenty of room for syncing to screw things up, along with other various downsides. In my opinion, they should just disallow Photos from directly opening a library from Dropbox at all (filed with Apple as bug 20902778. They actually already disallow creating or opening a Photos library that’s stored on iCloud Drive, presumably for similar reasons (though the resulting error message isn’t exactly user friendly). I’m also planning on adding checks for this in the next updates to iPhoto Library Manager and PowerPhotos, to at least warn people about putting a library in Dropbox.