Skip to content

Commit 082897a

Browse files
author
Guy Boertje
authored
Fix for Windows "unknown 0 0" identifier. (logstash-plugins#233)
* Fix for Windows "unknown 0 0" identifier. Make ruby string look like a C String. * make into module call + bump gemspec Fixes logstash-plugins#223
1 parent 95ef6f3 commit 082897a

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ addons:
77
- docker-ce
88
matrix:
99
include:
10-
- env: ELASTIC_STACK_VERSION=5.6.12
11-
- env: ELASTIC_STACK_VERSION=6.4.2
12-
- env: ELASTIC_STACK_VERSION=7.0.0-alpha1
10+
- env: ELASTIC_STACK_VERSION=5.6.15
11+
- env: ELASTIC_STACK_VERSION=6.6.1
12+
- env: ELASTIC_STACK_VERSION=7.0.0-beta1
1313
fast_finish: true
1414
install: ci/unit/docker-setup.sh
1515
script: ci/unit/docker-run.sh

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.1.10
2+
- 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)
3+
14
## 4.1.9
25
- Fixed issue where logs were being spammed with needless error messages [#224](https://github.com/logstash-plugins/logstash-input-file/pull/224)
36

lib/filewatch/winhelper.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@ def self.identifier_from_handle(handle, close_handle = true)
177177
private
178178

179179
def self.open_handle_from_path(path)
180-
CreateFileW(in_buffer(path), 0, 7, nil, 3, 128, nil)
181-
end
182-
183-
def self.in_buffer(string)
184-
utf16le(string)
180+
CreateFileW(utf16le(path), 0, 7, nil, 3, 128, nil)
185181
end
186182

187183
def self.char_pointer_to_ruby_string(char_pointer, length = 256)
@@ -192,7 +188,11 @@ def self.char_pointer_to_ruby_string(char_pointer, length = 256)
192188
end
193189

194190
def self.utf16le(string)
195-
string.encode("UTF-16LE")
191+
to_cstring(string).encode("UTF-16LE")
192+
end
193+
194+
def self.to_cstring(rubystring)
195+
rubystring + 0.chr
196196
end
197197

198198
def self.win1252(string)

logstash-input-file.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-input-file'
4-
s.version = '4.1.9'
4+
s.version = '4.1.10'
55
s.licenses = ['Apache-2.0']
66
s.summary = "Streams events from files"
77
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"

0 commit comments

Comments
 (0)