Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native filesystem events on Mac #472

Closed
bomma opened this issue Dec 6, 2011 · 21 comments
Closed

Use native filesystem events on Mac #472

bomma opened this issue Dec 6, 2011 · 21 comments
Labels
feature User visible and useful functionality macOS
Milestone

Comments

@bomma
Copy link

bomma commented Dec 6, 2011

After editing and saving a file using TextMate (http://macromates.com) SparkleShare does not sync that file.
Editing and saving the same file with TextEdit or VIM does cause SparkleShare to sync.

Maybe other programs besides TextMate are affected as well?
I consider this a serious defect since file changes might remain unnoticed.

I'm using SparkleShare 0.4.2 on OSX Lion 10.7.2 and TextMate Version 1.5.9 (1510).

Kind regards and thanks for all the great work!
Kevin.

@bomma
Copy link
Author

bomma commented Dec 6, 2011

Same behavior with version 1.5.10 (1631) of TextMate. SparkleShare does not notice the file has changed after saving.

@hbons
Copy link
Owner

hbons commented Dec 11, 2011

Do you know if SparkleShare detects a change in the file?
You should have some output in the Console.app.

@bomma
Copy link
Author

bomma commented Dec 12, 2011

Opening, editing and saving the file with TextMate does not cause any log entries in Console.
I suspect this is because of the way TextMate itself handles the files?

After editing and saving with TextMate it suffices to open the file with Vim (not even editing or saving) for SparkleShare to detect the changes and perform a sync.

So in short:
open, edit and save in TextMate: no log entries
afterwards opening in Vim causes sync

@hbons
Copy link
Owner

hbons commented Dec 14, 2011

I've reproduced it but I don't see how to fix this. SparkleShare just listens to events from the OS. I think this has to do with how TextMate saves files. Maybe file an issue there?

@hbons hbons closed this as completed Dec 14, 2011
@bomma
Copy link
Author

bomma commented Dec 14, 2011

I agree it probably is because of the way TextMate saves files.
However, I experience the same behavior with Sublime Text. So, maybe other apps are affected as well?

I still think this is real issue for a file syncing app such as SparkleShare. Apparently there are ways to alter files such that the filesystem events, that SparkleShare captures, are not triggered. I'll try to look into it myself too, maybe I can find useful information.

Update:
Watchdog does intercept edits from TextMate or Sublime Text. I'll check their source code.

Update2:
Libraries that use FSEvent such as rb-fsevent for Ruby don't exhibit this problem. How is SparkleShare doing this? Or can you give me a pointer where to look in the source code?

@kernch
Copy link

kernch commented Feb 3, 2012

If I've read the source correctly, every minute the whole file tree is searched for changes, and in a shorter interval, it is checked if the Mono file system listener has triggered, but at least it does never in my case.

To solve this problem (at least it is one for me :) ), I modified the source, to use FSEvents in Mono, as done here:
http://code.google.com/p/continuum-ide/source/browse/trunk/source/shared/DirectoryWatcher.cs

It needs further testing, but it seems to work well.

If someone is interested, I could post my modifications.

@hbons
Copy link
Owner

hbons commented Feb 4, 2012

@kernch yes please!

@hbons hbons reopened this Feb 4, 2012
@kernch
Copy link

kernch commented Feb 6, 2012

I uploaded it here:
http://pastebin.com/8eZLisDA

It's a replacement for SparkleMacWatcher.cs. It uses the MonoMac Libs. Right now, it's a very dumb hack. If a change is detected, all git repositories are updated. It can be made more precise, because FSEvents report the directory path in which the change happened, but I did not have the time to find out how exactly this is managed in SparkleShare.

@hbons
Copy link
Owner

hbons commented Feb 8, 2012

@kernch Thanks. I'll test this soon and hopefully integrate it. :)

@hbons hbons closed this as completed in 8081f4d Feb 11, 2012
@hbons
Copy link
Owner

hbons commented Feb 11, 2012

@kernch Thanks very much for submitting this, it's much more reliable and uses a lot less resources!

@bomma
Copy link
Author

bomma commented Aug 17, 2012

The use of the FSEvents API indeed solves the original issue. However, it seems the root folder of a (cloned) repo is not checked/monitored with the FSEvents API. Which leads to the same issue for files placed in the root folder.

For example:
editing ~/SparkeShare/Bla/file.txt with TextMate/Sublime Text does not result in a sync
editing ~/SparkeShare/Bla/subfolder/file.txt does

I would fix this myself, but I can't get SparkleShare to build on Mountain Lion:
./autoconf.sh fails with
./configure: line 2493: syntax error near unexpected token MONO_MODULE,' ./configure: line 2493: PKG_CHECK_MODULES(MONO_MODULE, mono >= 2.8)'

also the instructions for creating a mac bundle are not compatible with the latest version of MonoDevelop ("Create Mac Installer" does not exist anymore, you have to go through Project > SparkleShare options)

It would be great if anyone could give me a pointer on how to fix the build issue.

@hbons hbons reopened this Aug 17, 2012
@hbons
Copy link
Owner

hbons commented Aug 17, 2012

@bomma have you installed the SDK too?

@mogul
Copy link

mogul commented Aug 17, 2012

I just ran into this issue today... I'm using a TiddlyWiki (http://tiddlywiki.com/) as wiki.html on my Mac.

With the file in the root of a SparkleShare folder:

  • Edit the wiki.html in vi: So long as there's a diff, SparkleShare notices and gets right on propagating it.
  • Edit the wiki.html in my browser by adding to it: SparkleShare twiddles its thumbs and whistles, my blood pressure rises

I moved the wiki.html to a subdirectory:

  • Edit the wiki.html in my browser by adding to it: So long as there's a diff, SparkleShare notices and gets right on propagating it.

So, this still exists as a bug affecting innocent Mac users testing that SS works as advertised on files they stick in the root folder and edit... which it doesn't. :(

@mogul
Copy link

mogul commented Aug 17, 2012

BUT... Thank you all so much for at least documenting the problem here so I found the workaround (don't rely on SS to do anything with files in the top folder).

@hbons
Copy link
Owner

hbons commented Aug 18, 2012

I think it really depends on how certain apps save their files whether a file system event gets send that can be picked up. Why it doesn't work in a subfolder I don't know...

@mogul
Copy link

mogul commented Aug 18, 2012

Just to be clear, it does work in a sub folder.

@hbons
Copy link
Owner

hbons commented Aug 18, 2012

Sorry, that's what i meant.

@hbons hbons closed this as completed Aug 18, 2012
@bomma
Copy link
Author

bomma commented Aug 19, 2012

@hbons yes, sdk is installed

isn't it enough to turn off this check (SparkleController.cs line 87):

// Ignore changes in the root of each subfolder, these
// are already handled by the repository
if (Path.GetFileNameWithoutExtension (path).Equals (repo_name))
return;

Can't test it though, since I can't build :(

@hbons
Copy link
Owner

hbons commented Aug 19, 2012

@bomma did you try this:

$ export PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin:$PATH
$ export PKG_CONFIG=/Library/Frameworks/Mono.framework/Versions/Current/bin/pkg-config
$ export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig

@bomma
Copy link
Author

bomma commented Aug 19, 2012

@hbons Yes, I followed the steps on the wiki. I used to be able to build. But then I did a clean install of OS X, Xcode, Mono and MonoDevelop. That's when it stopped working.

mono --version
Mono JIT compiler version 2.10.9 (tarball Mon May 7 20:25:51 EDT 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: normal
Notification: kqueue
Architecture: x86
Disabled: none
Misc: debugger softdebug
LLVM: yes(2.9svn-mono)
GC: Included Boehm (with typed GC)

I installed automake etc using homebrew:

automake --version
automake (GNU automake) 1.12.2

@hbons
Copy link
Owner

hbons commented Aug 19, 2012

@bomma strange. it's also weird that it shows a syntax error... Maybe reclone the repo? And reinstall the make tools perhaps?

hbons added a commit that referenced this issue Aug 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature User visible and useful functionality macOS
Projects
None yet
Development

No branches or pull requests

4 participants