Question

I'm writing a script to move files out of a certain folder in my Dropbox when they are done syncing.

For example, I want to have a folder called "TrashBackup" that as soon as I put stuff in there,(after is done syncing) my server picks it up and moves it out of Dropbox into another place in the filesystem (ultimately deleting it from my laptop).

I was using pyinotify but the problem is that I don't know how to know when it is done syncing. I might end up moving before a possibly really big file isn't done transferring.

I was thinking of setting a timer to see when was the last time that files changed, and if its more than 20 minutes then go ahead and move it out of Dropbox.. But it seems like a hackaround. Also if I was transfering 1GB files I might be pushing my luck depending on Dropbox's speed and my local bandwith utilization.

Maybe I should start monitoring the .dropbox.cache folder? Any ideas?

Was it helpful?

Solution

Why not try using the Dropbox CLI? There are several methods in there that should prove useful to you.

For achieving your specific goal, I can think of two commands that would be useful: dropbox status, and dropbox filestatus. The former will return "Idle" when syncing is complete. The latter returns the sync status of one or more files.

OTHER TIPS

You could use the API, (specifically, /metadata: https://www.dropbox.com/developers/reference/api#metadata ) to poll that folder occasionally, (e.g. every 5-10 min) to see if anything new is there, and if so, perform the move as desired. The advantage of the API in this case is that the file will only show once it is done syncing anyway. (Monitoring .dropbox.cache is not recommended.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top