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

issue #450: linux driver: add :modify to default events listened to #502

Merged

Conversation

ColinDKelley
Copy link
Collaborator

Fix for issue #450 .

@ColinDKelley
Copy link
Collaborator Author

@ms-ati brought up the risk that adding :modify might lead to duplicate events.

That PR is all using stubs, so it doesn't disprove the possibility of duplicate events. I can try running an interactive test to see if that happens.

@ColinDKelley
Copy link
Collaborator Author

@ms-ati I ran this test on a Linux pod. It worked perfectly--no dups!

# cat listen-test.rb
require 'listen'

target = ARGV[0] or raise "no target given"
puts "listening to #{target}"

Listen.to(target) do |*args|
	puts Hash[[:modified, :added, :removed].zip(args)].inspect
end.start

puts "sleeping..."
sleep

# bundle exec ruby listen-test.rb . &
[1] 489
listening to .
sleeping...

# touch a.dat
{:modified=>[], :added=>["/srv/app/listen-test/a.dat"], :removed=>[]}
# rm a.dat
{:modified=>[], :added=>[], :removed=>["/srv/app/listen-test/a.dat"]}
# touch b.dat
{:modified=>[], :added=>["/srv/app/listen-test/b.dat"], :removed=>[]}
# echo more >> b.dat
{:modified=>["/srv/app/listen-test/b.dat"], :added=>[], :removed=>[]}
# mv b.dat c.dat
{:modified=>[], :added=>["/srv/app/listen-test/c.dat"], :removed=>["/srv/app/listen-test/b.dat"]}
# kill %1

@ms-ati
Copy link

ms-ati commented Nov 3, 2020

@ColinDKelley Awesome! Could you try editing a file and saving it, as opposed to running touch, as well?

@ms-ati
Copy link

ms-ati commented Nov 3, 2020

(that is -- not simply appending -- but editing and saving)

Copy link

@ms-ati ms-ati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Pending manual interactive test of editing and saving a file if possible

@ColinDKelley
Copy link
Collaborator Author

ColinDKelley commented Nov 3, 2020

@ms-ati I ran that test on a Linux pod and it worked exactly as expected. I tried both editing an existing file, and a new one.

# bundle exec ruby listen-test.rb . &
[1] 151
listening to .
sleeping...

# touch a.txt
{:modified=>[], :added=>["/srv/app/listen-test/a.txt"], :removed=>[]}

# vi a.txt
(added a line and pressed ZZ to save and exit)
{:modified=>["/srv/app/listen-test/a.txt"], :added=>[], :removed=>[]}

# vi b.txt
(added a line and pressed ZZ to save and exit)
{:modified=>[], :added=>["/srv/app/listen-test/b.txt"], :removed=>[]}

# rm a.txt b.txt
{:modified=>[], :added=>[], :removed=>["/srv/app/listen-test/a.txt", "/srv/app/listen-test/b.txt"]}

@ColinDKelley
Copy link
Collaborator Author

BTW, I've added a variant of the above tests to the README since they seem helpful to understand how it works overall.
#503

@ms-ati
Copy link

ms-ati commented Nov 4, 2020

cc @ioquatix looks like this PR is pending your formal review in Github?

@ColinDKelley
Copy link
Collaborator Author

I'm going to merge and release as v3.3.0.pre.3 so we can get some burn-in time. I'm still interested in your review though, @ioquatix!

@ColinDKelley ColinDKelley merged commit 76d5a00 into guard:master Nov 4, 2020
@ColinDKelley ColinDKelley deleted the issue-450/add_modify_event_to_linux_driver branch November 23, 2020 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants