cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 

Determine if file has finished synchronising

jdm2
Explorer | Level 3

I have a simple problem: 

I store some data in DropBox which is shared between multiple people

Several times people have started editing the data bnefore it has finished synchronising

What I want is a simple routine which I can add to my application which determines whether a named file is synchronised, i.e. it is the same as the cloud version.

If the file isn't synchronised I will simply wait for the automatic synchronisation to complete.

The application is written in C# and is running on Windows 7 and 10

I have looked quite hard but I cannopt find an answer to this, apparently simple, question apart from "look at the DropBox App" which is precisely what my users dont do!

1 Accepted Solution

Accepted Solutions

Re: Determine if file has finished synchronising

Dropboxer
Dropboxer

Dropbox doesn't offer an API for checking the status of the Dropbox desktop client like this, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

Dropbox does offer an API, but it is for communicating directly with the Dropbox servers, regardless of the state of the local Dropbox desktop client (if any). 

For this use case though, you could potentially implement some of this using code running on the local machine and talking to the Dropbox API. That is, for any particular file:

  • read the locally available file data and compute its "content hash" as documented here
  • call the Dropbox API /2/files/get_metadata endpoint for that file (or /2/files/list_folder[/continue] to list the contents of a folder) and get the relevant `content_hash` value
  • compare the the local and remote content hash values: if they match, you know you have the same data locally and remote; if they don't match, the data differs.

There are still race conditions possible with such a process though. E.g., the desktop client could sync down the new version of a file right after you check the content hash of the old one and before you compare it with the remote one, etc.

By the way, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints. 

View solution in original post

5 Replies 5

Re: Determine if file has finished synchronising

Dropboxer
Dropboxer

Thanks for reaching out to us here @jdm2, I hope you're having a good day!

The best way I can suggest to determine whether your files are up to date, would indeed be to check the desktop app's sync status by looking at the Dropbox icon.

The folder members could also check the file itself to see if it's showing the syncing icon  before opening the file.

As a work around, I could suggest moving the file out of the folder while it's being edited and move it back once finished. This removes the file from the shared folder, and acts as a way to let others know the file is being worked on.

If you happen to be using Microsoft Office files, you can check out the Dropbox Badge lets you know if others are also editing the file.

I hope this helps to some extent, let me know if you have any other questions - thanks!


Daphne
Community Moderator @ Dropbox
https://dropbox.com/support


Heart Did this post help you? If so, please give it a Like below. 
 Did this post fix your issue/answer your question? If so please press the 'Accept as Solution' button to help others find it.
 Still stuck? Ask me a question! (
Questions asked in the community will likely receive an answer within 4 hours!)

Re: Determine if file has finished synchronising

jdm2
Explorer | Level 3

Unfortunately none of your solutions work better than doing nothing.

My users don't actually know which files they should worry about. They are real users who are experts in what they use the application for but donb't understand computers at all.

Moving the files out would make things worse - every change is small and atomic and I would be copying the whole file back every 10 seconds or less. DropBox does a marvelous job of propagating such changes to other users so crashes only affect the session in question. 

The lack of such functionality seems like a real hole in DropBox. It does everything else I need it to autromatically,

I just want to be able to observe it. It must be possible since the file explorer in Windows can display the correct badge on each file according to whether it is synchronised or not. 

Re: Determine if file has finished synchronising

Dropboxer
Dropboxer

Thanks or getting back to me here @jdm2!

I completely understand that the steps I mentioned aren't ideal for you, the way each person uses Dropbox can vary a great deal.

The desktop app will sync any changes that are made and available on the web as soon as they're made. This should mean that when the file shows , the file is up to date and reflecting the version from the web.

Since the sync icons aren't ideal for you, can you let me know a little more detail how you would want to observe the versions locally and online?

If we don't have a way to do this through the app itself other than the sync status, there may be some users here who could make some suggestions based on how you'd like to do this (via command line perhaps or API).

Keep me posted!


Daphne
Community Moderator @ Dropbox
https://dropbox.com/support


Heart Did this post help you? If so, please give it a Like below. 
 Did this post fix your issue/answer your question? If so please press the 'Accept as Solution' button to help others find it.
 Still stuck? Ask me a question! (
Questions asked in the community will likely receive an answer within 4 hours!)

Re: Determine if file has finished synchronising

jdm2
Explorer | Level 3

As I said in my original request

I want a subroutine which I can call in my application which takes a filename  as argument and returns a status to indicate ideally the following statuses:

  • The file is in DropBox and is synchronised to the cloud
  • The file is in DropBox but isn't yet synchronised to the cloud
  • The DropBox Service isn't running
  • The file isn't in DropBox

I've looked through the API and I cannot find anything which gives this, to me fairly fundamental, information. I'm very happy to write the code if it is in the API, I just need the information as to how to find the information I need.

I don't like command line or web scrapers or similar because they are maintenance nightmares. I also don't like unsupported mechanisms for the same reason.

 

Re: Determine if file has finished synchronising

Dropboxer
Dropboxer

Dropbox doesn't offer an API for checking the status of the Dropbox desktop client like this, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

Dropbox does offer an API, but it is for communicating directly with the Dropbox servers, regardless of the state of the local Dropbox desktop client (if any). 

For this use case though, you could potentially implement some of this using code running on the local machine and talking to the Dropbox API. That is, for any particular file:

  • read the locally available file data and compute its "content hash" as documented here
  • call the Dropbox API /2/files/get_metadata endpoint for that file (or /2/files/list_folder[/continue] to list the contents of a folder) and get the relevant `content_hash` value
  • compare the the local and remote content hash values: if they match, you know you have the same data locally and remote; if they don't match, the data differs.

There are still race conditions possible with such a process though. E.g., the desktop client could sync down the new version of a file right after you check the content hash of the old one and before you compare it with the remote one, etc.

By the way, those are links to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints. 

View solution in original post

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?