We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

Stephen B.25's avatar
Stephen B.25
Collaborator | Level 9
2 years ago

linux inotify on file in Dropbox: no notification of update

I want to send a message between two of my Dropbox devices which are otherwise invisible to each other.

 

I am trying to do this by updating content of a file.

 

$echo test > ~/Dropbox/compound

 

I have a put inotifywait on  ~/Dropbox/compound and do not receive notification that the file has been updated. If I access the file by some other means, then I will receive a notification of that activity, but not when Dropbox client updates a file through its own notification system. 

 

Both clients status is  `up to date`.

 

 

  • Stephen B.25's avatar
    Stephen B.25
    2 years ago

    Ah that's it. inotify watches the file's handle not the name. So if Dropbox creates a new file then inotify loses its reference. 

     

    So I have created a dedicated message subdirectory in Dropbox and put the watch on that *directory*. Now I am notified of changes to 'the file'

     

    Thanks very much for your help. 

     

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Stephen B.25 wrote:

    ...

    I am trying to do this by updating content of a file.

     

    $echo test > ~/Dropbox/compound

     

     

    I have a put inotifywait on  ~/Dropbox/compound and do not receive notification that the file has been updated. ...


    Hi Stephen B.25,

    For sure there are better and more secure ways to achieve the same, in spite it's still interesting idea. In all cases when you change particular file inotifywait should react. I just checked it out and it's working. One thing you can think about is the word "updating"! 🤔 Do you actually actualize your file? Take in mind if particular file is uploaded more than single time with the same content, only first time (the actual change) is considered update. All rest uploads are just ignored! Are you repeating the same command again and again without changing "test" inside? 🧐 If so, that's your issue! 😁 You don't really update your file and that's why no any reaction can be expected. 😉 Fix it.

    One more thing you should take in mind, on update event, Dropbox application doesn't update the file, but replace it in fact. This can push in confusion some monitoring systems in some cases (the same when some editor replace particular file instead of update it, Dropbox removes associated link, if any). Dropbox behaves like such replacing programs! This can affect your code in some special cases only.

    Hope this helps.

    • Stephen B.25's avatar
      Stephen B.25
      Collaborator | Level 9

      Ah that's it. inotify watches the file's handle not the name. So if Dropbox creates a new file then inotify loses its reference. 

       

      So I have created a dedicated message subdirectory in Dropbox and put the watch on that *directory*. Now I am notified of changes to 'the file'

       

      Thanks very much for your help.