Skip to content

Fix for Windows "unknown 0 0" identifier. #233

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

Merged
merged 2 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ addons:
- docker-ce
matrix:
include:
- env: ELASTIC_STACK_VERSION=5.6.12
- env: ELASTIC_STACK_VERSION=6.4.2
- env: ELASTIC_STACK_VERSION=7.0.0-alpha1
- env: ELASTIC_STACK_VERSION=5.6.15
- env: ELASTIC_STACK_VERSION=6.6.1
- env: ELASTIC_STACK_VERSION=7.0.0-beta1
fast_finish: true
install: ci/unit/docker-setup.sh
script: ci/unit/docker-run.sh
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.1.10
- Fixed problem in Windows where some paths would fail to return an identifier ("inode"). Make path into a C style String before encoding to UTF-16LE. [#232](https://github.com/logstash-plugins/logstash-input-file/issues/232)

## 4.1.9
- Fixed issue where logs were being spammed with needless error messages [#224](https://github.com/logstash-plugins/logstash-input-file/pull/224)

Expand Down
12 changes: 6 additions & 6 deletions lib/filewatch/winhelper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,7 @@ def self.identifier_from_handle(handle, close_handle = true)
private

def self.open_handle_from_path(path)
CreateFileW(in_buffer(path), 0, 7, nil, 3, 128, nil)
end

def self.in_buffer(string)
utf16le(string)
CreateFileW(utf16le(path), 0, 7, nil, 3, 128, nil)
end

def self.char_pointer_to_ruby_string(char_pointer, length = 256)
Expand All @@ -192,7 +188,11 @@ def self.char_pointer_to_ruby_string(char_pointer, length = 256)
end

def self.utf16le(string)
string.encode("UTF-16LE")
to_cstring(string).encode("UTF-16LE")
end

def self.to_cstring(rubystring)
rubystring + 0.chr
end

def self.win1252(string)
Expand Down
2 changes: 1 addition & 1 deletion logstash-input-file.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-input-file'
s.version = '4.1.9'
s.version = '4.1.10'
s.licenses = ['Apache-2.0']
s.summary = "Streams events from files"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down