daveallie / entangler

Two way file syncer using platform native notify
MIT License
8 stars 6 forks source link

Revert "Prevent File.read on directories" #14

Closed ghiculescu closed 6 months ago

ghiculescu commented 6 months ago

Reverts daveallie/entangler#13

Sorry @daveallie I should have commented on the PR.

We are worried this will swallow changes in the directory.

The bug we are trying to fix, is really a bug in listen, not entangler.

daveallie commented 6 months ago

We are worried this will swallow changes in the directory.

Sub-directories should be fine with this change?

3.2.2 :001 > require 'listen'
3.2.2 :002 > l = Listen::Listener.new("#{ENV['HOME']}/tmp") { |m, a, r| puts(modified: m, added: a, removed: r) }
3.2.2 :003 > l.start

// ran the following here
cd tmp
mkdir asdf
ln -s asdf asdff
mkdir asdff/nested
echo 'hi' > asdff/nested/new-file
// end

{:modified=>[], :added=>["/Users/david/tmp/asdff"], :removed=>[]}
{:modified=>[], :added=>["/Users/david/tmp/asdf/nested/new-file"], :removed=>[]}

3.2.2 :004 > File.directory?('tmp/asdff')
 => true
3.2.2 :005 > File.directory?('tmp/asdff/nested')
 => true
3.2.2 :006 > File.directory?('tmp/asdff/nested/new-file')
 => false
ghiculescu commented 6 months ago

The real problem is that listen is emitting a "change" event but it's for a directory, not a file. We think that's becuase we're running it via a docker mount, but haven't replicated that yet.

There shouldn't be symlinks involved at all (unless docker adds them).

daveallie commented 6 months ago

ahhhh understood, right. no idea what docker does under the hood tbh, it's all a bit blackmagic