diff --git a/CHANGELOG.md b/CHANGELOG.md index aa5a3d6..11bd2ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 4.1.16 + - Introduced new `check_archive_validity` settings to enable gzipped files verification, issue [#261](https://github.com/logstash-plugins/logstash-input-file/issues/261) + ## 4.1.15 - Fixed bug in conversion of sincedb_clean_after setting [#257](https://github.com/logstash-plugins/logstash-input-file/pull/257) diff --git a/lib/filewatch/read_mode/handlers/read_zip_file.rb b/lib/filewatch/read_mode/handlers/read_zip_file.rb index 37ffb2f..9a86436 100644 --- a/lib/filewatch/read_mode/handlers/read_zip_file.rb +++ b/lib/filewatch/read_mode/handlers/read_zip_file.rb @@ -20,7 +20,6 @@ def handle_specifically(watched_file) key = watched_file.sincedb_key if @settings.check_archive_validity && corrupted?(watched_file) - #watched_file.listener.deleted watched_file.unwatch else begin @@ -38,10 +37,8 @@ def handle_specifically(watched_file) end watched_file.listener.eof rescue ZipException => e - logger.error("Cannot decompress the gzip file at path: #{watched_file.path}", :exception => e, - :class => e.class.name, - :message => e.message, - :backtrace => e.backtrace) + logger.error("Cannot decompress the gzip file at path: #{watched_file.path}", :exception => e.class, + :message => e.message, :backtrace => e.backtrace) watched_file.listener.error else sincedb_collection.store_last_read(key, watched_file.last_stat_size) @@ -65,7 +62,8 @@ def close_and_ignore_ioexception(closeable) begin closeable.close rescue Exception => e # IOException can be thrown by any of the Java classes that implement the Closable interface. - logger.warn("Ignoring an IOException when closing an instance of #{closeable.class.name}", "exception" => e) + logger.warn("Ignoring an IOException when closing an instance of #{closeable.class.name}", + :exception => e.class, :message => e.message, :backtrace => e.backtrace) end end @@ -80,7 +78,8 @@ def corrupted?(watched_file) return false rescue ZipException => e duration = Time.now - start - logger.warn("#{watched_file.path} is corrupted, #{duration} secs, message: #{e.message}") + logger.warn("Detected corrupted archive #{watched_file.path} file won't be processed", :message => e.message, + :duration => duration.round(3)) return true ensure close_and_ignore_ioexception(gzip_stream) unless gzip_stream.nil? diff --git a/logstash-input-file.gemspec b/logstash-input-file.gemspec index df5ac25..75a824c 100644 --- a/logstash-input-file.gemspec +++ b/logstash-input-file.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-input-file' - s.version = '4.1.15' + s.version = '4.1.16' 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"