- File.expand_path("/....") on windows platform returns "C:/...." which

is expected but not in our monkeypatching to work around other bugs.

  This should resolve logstash's known windows 'file input' problems and
  whatnot. I've tested this on a Windows Server 2012 EC2 instance
  provided by the Alex Corley at Zenoss <3

  Test config showed file inputs working. I was able to watch
  "C:\test.log" and edit the file with notepad, adding lines, and
  logstash would see new events show up when I saved.
This commit is contained in:
Jordan Sissel 2013-05-01 05:28:36 +00:00
parent c62c43ed69
commit 3683238da2

View file

@ -31,6 +31,7 @@ class File
alias_method :expand_path_JRUBY_6970, :expand_path
def expand_path(path, dir=nil)
#p :expand_path => [path, dir]
if path =~ /(jar:)?file:\/.*\.jar!/
#p :expand_path_path => [path, dir]
jar, resource = path.split("!", 2)
@ -39,7 +40,17 @@ class File
# Nothing after the "!", nothing special to handle.
return expand_path_JRUBY_6970(path, dir)
else
return "#{jar}!#{expand_path_JRUBY_6970(resource, dir)}"
resource = expand_path_JRUBY_6970(resource, dir)
# TODO(sissel): use LogStash::Util::UNAME
if RbConfig::CONFIG["host_os"] == "mswin32"
# 'expand_path' on "/" will return "C:/" on windows.
# So like.. we don't want that because technically this
# is the root of the jar, not of a disk.
puts :expand_path => [path, "#{jar}!#{resource.gsub(/^[A-Z]:/, "")}"]
return "#{jar}!#{resource.gsub(/^[A-Z]:/, "")}"
else
return "#{jar}!#{resource}"
end
end
elsif dir =~ /(jar:)?file:\/.*\.jar!/
jar, dir = dir.split("!", 2)