Last active
December 22, 2015 17:09
-
-
Save dpb587/6504374 to your computer and use it in GitHub Desktop.
Add inode correcting code-for Windows /from https://github.com/cityindex/logsearch-development-flow/issues/174#issuecomment-24123708
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
--- 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