Skip to content

Instantly share code, notes, and snippets.

@dpb587
Last active December 22, 2015 17:09
Show Gist options
  • Save dpb587/6504374 to your computer and use it in GitHub Desktop.
Save dpb587/6504374 to your computer and use it in GitHub Desktop.
--- a/lib/filewatch/watch.rb
+++ b/lib/filewatch/watch.rb
@@ -6,6 +6,7 @@ module FileWatch
public
def initialize(opts={})
+ @iswindows = ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) != nil)
if opts[:logger]
@logger = opts[:logger]
else
@@ -68,7 +69,13 @@ module FileWatch
next
end
- inode = [stat.ino, stat.dev_major, stat.dev_minor]
+ if @iswindows
+ fileId = Winhelper.GetWindowsUniqueFileIdentifier(path) #Forcing this WinHelper call also seems to ensure that subsiquent stat.size calls don't contain stale data
+ inode = [fileId, stat.dev_major, stat.dev_minor]
+ else
+ inode = [stat.ino.to_s, stat.dev_major, stat.dev_minor]
+ end
+
if inode != @files[path][:inode]
@logger.debug("#{path}: old inode was #{@files[path][:inode].inspect}, new is #{inode.inspect}")
yield(:delete, path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment