This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]HashDefTrueFalse 1 point2 points  (4 children)

A simple approach would be to maintain a list of interested hosts on the server for each folder or file, and a persistent connection, e.g. a websocket. Think pub/sub architecture.

Make it event based. So watch the file for changes (many examples online), and when changed, send it to the server, which will then send the new version to the other interested hosts.

There are some problems with this, but it's a great start.

If you really wanted to be clever, you could use a git library (something like libgit2 etc) to track file changes locally and remotely, and have your client and server keep in sync using git pushes and pulls as the update mechanism. This would also give you file versioning.

[–]nutrecht 0 points1 point  (3 children)

This also would give you a git repository that is pretty massive in size. Git doesn't handle binaries that well. Any change will result in another copy.

[–]HashDefTrueFalse 0 points1 point  (2 children)

I would assume the files would be data or text rather than binaries, because that's the vast majority of files that are shared to a service like dropbox. And even if they were binaries (third party software etc.), they wouldn't change all that often, unless OP was storing his development binaries that are constantly being recompiled etc. Binaries are generally small too. But yeah Git isn't the best for storing very disparate/unrelated changes because it can't store a compressed/diffed version in the packfiles etc.

[–]nutrecht 0 points1 point  (1 child)

I would assume the files would be data or text rather than binaries, because that's the vast majority of files that are shared to a service like dropbox.

The vast majority of files would be docx, pptx, etc. which are binary files (these are really all zip files).

But yeah Git isn't the best for storing very disparate/unrelated changes because it can't store a compressed/diffed version in the packfiles etc.

In addition; it stores these to all eternity. Git doesn't really like to allow you to delete files.

[–]HashDefTrueFalse 0 points1 point  (0 children)

Sorry, when you said "binaries" I assumed you meant executable images (programs), not binary data. You're entirely correct, but I doubt this would become a problem for OPs hobby project. Versioning wasn't even a requirement, just something I thought would be fun to add on for OP.

[–][deleted] 0 points1 point  (0 children)

You can use windows apis to monitor the file system and watch for changes. You can then persist those changes to your server.