Skip to content

Commit

Permalink
v2.4.4. Improvement.
Browse files Browse the repository at this point in the history
- v2.4.4 October 10, 2013
	- Added the ability to turn off following links by setting
`followLinks` to `false`
		- Thanks to [Fredrik Noren](https://github.com/FredrikNoren) for
[pull request bevry#47](bevry#47)
	- Prefer accuracy over speed
		- Use the watch method by default, but don't trust it at all, always
double check everything
  • Loading branch information
balupton committed Oct 9, 2013
1 parent fa5b296 commit ef498d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## History

- v2.4.4 October 10, 2013
- Added the ability to turn off following links by setting `followLinks` to `false`
- Thanks to [Fredrik Noren](https://github.com/FredrikNoren) for [pull request #47](https://github.com/bevry/watchr/pull/47)
- Prefer accuracy over speed
- Use the watch method by default, but don't trust it at all, always double check everything

- v2.4.3 April 10, 2013
- More work on swap file handling

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "watchr",
"version": "2.4.3",
"version": "2.4.4",
"description": "Better file system watching for Node.js",
"homepage": "https://github.com/bevry/watchr",
"keywords": [
Expand Down
15 changes: 7 additions & 8 deletions src/lib/watchr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ Watcher = class extends EventEmitter
- eventName - either 'rename' or 'change'
- THIS VALUE IS ALWAYS UNRELIABLE AND CANNOT BE TRUSTED
- filename - child path of the file that was triggered
- This value can also be unrealiable at times
- Both methods
- For deleted and changed files, it will fire on the file
- For new files, it will fire on the directory
Expand Down Expand Up @@ -357,6 +358,9 @@ Watcher = class extends EventEmitter
currentStatArgument = args[0]
previousStatArgument = args[1]

###
# Don't trust the watch method AT ALL
##
# Can we trust the original event handlers?
# We only trust the change event and if we already know about the file it is reporting
# Otherwise chances are something else has changed in the directory than just the file being reported
Expand All @@ -367,6 +371,7 @@ Watcher = class extends EventEmitter
@log('debug', 'forwarding initial change detection to child:', childFileRelativePath, 'via:', fileFullPath)
childFileWatcher.listener('change', '.')
)()
###

# Prepare: is the same?
isTheSame = =>
Expand Down Expand Up @@ -401,14 +406,8 @@ Watcher = class extends EventEmitter
# Error?
return @emit('error', err) if err

# Find changed files if we do not have reliable data that something specific has changed
# currently we only consider it unreliable if we are using the watch method and didn't receive a path with the event
# on most machines, we will receive a path, and it will be accurate
# the watchFile method also tends to be quite accurate
# so under this use case, we may get something like ['rename',null] which may mean a swap file was renamed to a file
# that we are already aware about so we'll have to check the files we are aware about for changes
# if we get something like ['rename','.subl111.tmp'] - we hope that the correct change event already fired
if eventNameArgument and filenameArgument is null
# The watch method is fast, but not reliable, so let's be extra careful about change events
if method is 'watch'
eachr @children, (childFileWatcher,childFileRelativePath) =>
# Skip if the file has been deleted
return unless childFileRelativePath in newFileRelativePaths
Expand Down

0 comments on commit ef498d8

Please sign in to comment.