-
Notifications
You must be signed in to change notification settings - Fork 246
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
rework record logic #308
Closed
Closed
rework record logic #308
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c6bb44f
Fix unintended amalgamation of root files and the directory list
driskell 2f8ad95
update tests and + fix Record build logic
e2 6b00068
rework Adapter specs
e2 91bd5f2
extract simulator to SimulatedDarwin
e2 6bbca69
make recursion configurable (Darwin)
e2 1b8d1c8
test all combinations on Travis
e2 9a5ded7
update to RSpec 3.2
e2 174cbdb
fix single spec on Rubinius
e2 a35c2b2
run polling acceptance tests separately
e2 67f50e7
show warning when recursion is off (Darwin)
e2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module Listen | ||
module Adapter | ||
class SimulatedDarwin < Linux | ||
def self.usable? | ||
os = RbConfig::CONFIG['target_os'] | ||
return false unless const_get('OS_REGEXP') =~ os | ||
/1|true/ =~ ENV['LISTEN_GEM_SIMULATE_FSEVENT'] | ||
end | ||
|
||
class FakeEvent | ||
attr_reader :dir | ||
|
||
def initialize(watched_dir, event) | ||
# NOTE: avoid using event.absolute_name since new API | ||
# will need to have a custom recursion implemented | ||
# to properly match events to configured directories | ||
@real_path = full_path(event).relative_path_from(watched_dir) | ||
@dir = "#{Pathname(watched_dir) + dir_for_event(event, @real_path)}/" | ||
end | ||
|
||
def real_path | ||
@real_path.to_s | ||
end | ||
|
||
private | ||
|
||
def dir?(event) | ||
event.flags.include?(:isdir) | ||
end | ||
|
||
def moved?(event) | ||
(event.flags & [:moved_to, :moved_from]) | ||
end | ||
|
||
def dir_for_event(event, rel_path) | ||
(moved?(event) || dir?(event)) ? rel_path.dirname : rel_path | ||
end | ||
|
||
def full_path(event) | ||
Pathname.new(event.watcher.path) + event.name | ||
end | ||
end | ||
|
||
private | ||
|
||
def _process_event(watched_dir, event) | ||
ev = FakeEvent.new(watched_dir, event) | ||
|
||
_log( | ||
:debug, | ||
"fake_fsevent: #{ev.dir}(#{ev.real_path}=#{event.flags.inspect})") | ||
|
||
_darwin.send(:_process_event, watched_dir, [ev.dir]) | ||
end | ||
|
||
def _darwin | ||
@darwin ||= Class.new(Darwin) do | ||
def _configure(*_args) | ||
# Skip FSEvent setup | ||
end | ||
end.new(mq: @mq) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails to add the directory name to the parent folder's entry list.
For example, if we have a simple directory containing one folder,
path
, and within that,folder
, and within that a file calledREADME
, the resulting tree would be:It should be:
Otherwise when
Directory::scan
is processing deletion forpath
, it will never recursefolder
and not actually raise any deletion events, which it should do forREADME
This seems to work, and I'll look at making a test unless you're able to find it easier?