Dropbox hackathon

Daniel García
Produkt Blog
Published in
4 min readFeb 1, 2015

Open sourcing Minniebox

A week ago we had the pleasure of being part of Dropbox’s first London hackathon. What an amazing experience!

Like a normal hackathon, we had 24 hours to come up with whatever piece of code using Dropbox API.

With Victor and I being iOS developers @produkt, and Hugo being very comfortable designing for that platform, our decision was very straight forward.

Let’s make an iOS app!

MinnieBox — DaisyDisk’s very little brother

Hugo came up with a great idea for this hackathon. For those who may not know DaisyDisk app for Mac, it is a life saver. In two lines, DaisyDisk is a

disk analyzer tool that visualizes hard disk usage and allows to free up hard disk space.

MinnieBox wants to become DaisyDisk’s little brother, for your Dropbox content. Basically, MinnieBox scans all your dropbox files and presents them to you in a visual way, so you can easily free up some Dropbox space.

Minniebox workflow is very simple — two screens.
On the left tab all your dropbox files are displayed filtered by size. Find the stuff you want to get rid of and simply swipe for sending it to MinnieBox tab.
The right tab will contain all the files you have previously sent to MinnieBox these files are ready to be deleted.

The insights: playing with Dropbox API TL;DR

At first sight, this could seem like an easy app to develop. And it is not a huge challenge, but it has some pitfalls.

The first thing you have to deal with, is getting all the information from dropbox to calculate how all your dropbox account space is beeing spent.
Our first approach was trying to get all this information using the /metadata from the Core API. This simple API endpoint returns all the information of an specific path, including the size of each file.

Sounds great right ? you can simply fetch the metadata for the root path and present it on screen !
well… not really …
Unfortunately, Dropbox API returns “0 bytes” for folders metadata. So you have to actually know the size of each file inside a folder in order to know the size of that folder. And folders can include other folders. And those can also include more folders … you get the point.

Well, fetching for all the paths in your dropbox account recursively looks like a lot of fetching…
That could take looooooong time to get all the neccesary information to calculate all your used space.

Fortunately, Steve Marx (Product Manager at Dropbox) was around to suggest us to take a look at the Dropbox /delta API. He also had written a post about how to efficiently enumerate your files using this API.

/delta endpoint returns the metadata for all your updated files since last time you check. But the first time you check, it returns all the metadata for all your files.
You can call multiple times to this endpoint until you get all the files and folders stored in your account, but the problem is that you will end up with a flat list of them. We will have to build the folders tree, but this will save us a lot of time, network data, and power.

Composite Pattern Diagram form Wikipedia

After getting all the metadata, we iterate all the nodes (folders/files) and reconstruct the whole dropbox tree. We used the Composite Pattern to represent the nodes tree.

We created a class (that we called MBInode) that represents a node, holds all its metadata, and stores its childs nodes (other MBInodes). For an efficient and fast construction of the tree, we wanted to simply add a new node to the root node (/) and it should take care of storing it or passing it to the correct child.

When you add a new node to an MBInode, it reads the new node path to know if it is its own child, or a child of a child.

If it is its own child , it simply adds the node to its child nodes collection (in this case an NSSet), but if it isn’t, it looks for the inmediate parent node inside the child nodes collection, and add the new node to its parent. This occurs recursively until the new node is stored into the correct parent node.

Open-sourcing everything

During the Dropbox hackathon we didn’t have time to finish MinnieBox, at least not how we wanted it.
We believe MinnieBox is a tool that people might want to use (at least we will!), but we are not comfortable shipping it yet. There is still work to do, and sharing it will help us meet our goal quicker and better. For that reason we have decided to open-source both the design and the code.

Feel free to grab the code here and the sketch files for the design here.

Last detail

For those of you who are curious about the name… Being Daisy Disk our source of inspiration, makes sense to call it Minnie(drop)Box.

--

--