Over the years, various syncing applications have bugged me with how often they spike to 100% CPU usage, their memory usage, pricing, and other issues. So I set out to write my own for fun! Spoiler: in the end, I learned you really should just use Dropbox 🤣 However, I did manage to make it work, and reliably enough that I’m using it for some personal files, so I’m open-sourcing it in case anyone wants to check it out.
The project is called Flare, which is in reference to the ‘blaze’ part of the backend service’s name.
It is essentially a Dropbox clone that performs 2-way sync of files between a local folder and ‘the cloud’ (in this case, Backblaze B2). These files will then sync to many computers automatically. You could use it to keep a folder synced for members of a team, for instance. And because it uses Backblaze, your storage costs are miniscule.
It’s written in Swift, available at github.com/chrishulbert/flare, and (more-or-less) works!
You really shouldn’t use this for important use, it’s a hobby project!
foo/bar/yada/blah.txtand modify blah.txt. Foo, bar, and yada’s last modified date will unfortunately not change. In a slightly better case, if you rename blah.txt to blah2.txt, the immediate parent folder (yada) will change it’s last modified date, however grandparents and great-grandparents (foo and bar, respectively) will not. This is because those operating systems want to remain efficient. However this means that Flare cannot simply look at a last modified date and determine that it can skip an entire folder tree: it must still scan every subfolder and every file to see if anything has changed, every time it syncs. This is the biggest limitation of Flare. This could be resolved with an always-running agent, but then you’d also need a full-scan when launching the agent to catch any changes that occurred while it wasn’t running. However, for a hobby project I simply do not have the time to pursue this (I have children to chase!). Also, B2 does not give you folder last modified dates either, so you’d need a custom backend.
These instructions are only for macOS. However, the app should compile fine on any Swift-supported platform if you see fit.
brew install chrishulbert/flare/flare
Swift really won me over with it’s ability to model all the edge-cases of synchronisation in a way that wouldn’t compile unless I handled every one. A great example of this is the switch statement in ListingReconciliation.swift. This is how a good language fosters safe code, and I’m a huge fan. So: thanks, Chris Lattner.
Thanks for reading, I hope this interests someone, and have a great week!
Legals: I take no responsibility; give no guarantee/warranty for this project.
Photo by Christopher Cambpell via Unsplash
Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.
(Comp Sci, Hons - UTS)
iOS Developer (Freelancer / Contractor) in Australia.
I have worked at places such as Google, Cochlear, Assembly Payments, News Corp, Fox Sports, NineMSN, FetchTV, Woolworths, and Westpac, among others. If you're looking for help developing an iOS app, drop me a line!