Showing posts tagged nsync

nodejs dropbox clone: nsync

I have created a github repo for the project: https://github.com/aishwar/nsync

The focus of this project (at this stage) is not on supporting advanced features (e.g. versioning, conflict resolution etc.) in file synchronization, but rather creating a basic app that provides file synchronization in a cross-platform way.

Here are the tasks I believe need to be done for us to have a basic working software:

  1. Running the app in client-mode/server-mode
    Terminology: Each machine where changes to files can happen and that need to be synchronized is a client. The server is the coordinator of changes. All changes in the clients are sent to the server. When a client makes changes to the file system and informs the server, the server updates its copy with those changes and then informs the other clients.
  2. Security mechanism of the server to ensure client connects to the intended server. If we have a client watching folder ‘A’ and another client watching folder ‘B’, we do not want client watching folder ‘A’ to try and sync with server for folder ‘B’
  3. File System representative object generation
    Generating JSON representation of the file system. The JSON object should contain the names of the files and the hash value to represent their content.
  4. Comparison of two file system objects to identify:
    file adds,
    file deletes, and 
    file changes
  5. Client/Server delta computation on the server
  6. Client/Server sending file-system updates and ensuring it gets done

We will keep our conflict resolution simple: Last client wins. If clients A and B update a file. The last one to inform the server of the file update will be the winner regardless of who updated first.

Creating a dropbox clone using nodejs

As I was surfing the interwebs, I came across lipsync. Lipsync is an open source dropbox clone. I was looking for something like this. I thought “perfect, I can use this now”. Only to realize, a minute later, it doesn’t work in Windows. Bummer.

But this also got me excited. I could try building one. And what better way to do it than nodejs. Afterall, here is what nodejs is supposed to be (from the official site):

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

And nodejs runs on multiple platforms. Ok, time to try this out.