logstash-integration-aws 7.1.5-java → 7.1.6-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77814112cf4be9a2155d84247dab1157ee8a9b1a075b92ed3888b7a9d66ccf8a
4
- data.tar.gz: bb70280e923a6375f7ec8834f42c753483c150325bb4fc566d213f3addc78a61
3
+ metadata.gz: 163e3851149d6d1e0be9602a1298359cc355f57177bad417429a5c39840ca768
4
+ data.tar.gz: deadfc6ba818c8081ad796fc2180e80c189da9842b97e1cace008bb2fab44432
5
5
  SHA512:
6
- metadata.gz: 9999ddefbccde321a77933296295295550fa4e2651af60f8f7cd0dfb615dece6300bb34a010d6c3600d4313d53ed34f75274c91c662083c165cbdd1df69cd90a
7
- data.tar.gz: 771d356b646e22616732ff35ed1ef6df791c4bf423e38dcbd6b7460bb0992fb2a6176c0a2cff74bc3c67e93353356f152a156edf2ecbc3c05eaac112210dcea3
6
+ metadata.gz: 21eaa2c5146017e907a18f7e1b1f479ecf708fd6a89fc771c1283a85a919545e02c064d5944ea29ee5d52bb562079816e8365a1063e810e22c5c6ab7a4b6a6b0
7
+ data.tar.gz: b65ae6b87d7340c8494877f4be303b83042a93769d99ade69c9d7bc27eced6bf3286fbfd30812cf299495ae0d920e124dbce27153c15bcac313d375bb69aaf6c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 7.1.6
2
+ - Clean up plugin created temporary dirs at startup [#39](https://github.com/logstash-plugins/logstash-integration-aws/pull/39)
3
+
1
4
  ## 7.1.5
2
5
  - Fix external documentation links [#35](https://github.com/logstash-plugins/logstash-integration-aws/pull/35)
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.1.5
1
+ 7.1.6
@@ -395,8 +395,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
395
395
  @crash_uploader = Uploader.new(bucket_resource, @logger, CRASH_RECOVERY_THREADPOOL)
396
396
 
397
397
  temp_folder_path = Pathname.new(@temporary_directory)
398
- files = Dir.glob(::File.join(@temporary_directory, "**/*"))
399
- .select { |file_path| ::File.file?(file_path) }
398
+ all_files = Dir.glob(::File.join(@temporary_directory, "**/*"))
399
+ removed_dirs = remove_empty_dirs(all_files)
400
+ files = all_files.select { |file_path| !removed_dirs.include?(file_path) && ::File.file?(file_path) }
400
401
  under_recovery_files = get_under_recovery_files(files)
401
402
 
402
403
  files.each do |file_path|
@@ -439,4 +440,20 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
439
440
  end
440
441
  skip_files
441
442
  end
443
+
444
+ # Sorts explored files in desc order
445
+ # And proceeds bottom-up traversal remove operation if dir is empty
446
+ # Returns removed set to avoid duplicate Dir.glob process
447
+ def remove_empty_dirs(files)
448
+ removed_dirs = Set.new
449
+ files.sort { |x, y| y.length - x.length } # make sure to remove from leaf node
450
+ .select { |path| ::File.directory?(path) }
451
+ .select { |path| (Dir.entries(path) - %w[ . .. ]).empty? } # current and parent dirs escape
452
+ .each do |path|
453
+ @logger.debug? && @logger.debug("Removing empty temporary file", :path => path)
454
+ FileUtils.rm_f(path)
455
+ removed_dirs << path
456
+ end
457
+ removed_dirs
458
+ end
442
459
  end
@@ -1,4 +1,4 @@
1
1
  # AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
2
2
 
3
3
  require 'jar_dependencies'
4
- require_jar('org.logstash.plugins.integration.aws', 'logstash-integration-aws', '7.1.5')
4
+ require_jar('org.logstash.plugins.integration.aws', 'logstash-integration-aws', '7.1.6')
@@ -229,4 +229,33 @@ describe LogStash::Outputs::S3 do
229
229
  end
230
230
  end
231
231
  end
232
+
233
+ context "remove empty dirs" do
234
+
235
+ before do
236
+ allow(File).to receive(:directory?).with('/path/to/bar-empty').and_return(true)
237
+ allow(File).to receive(:directory?).with('/path/to/foo/empty-dir').and_return(true)
238
+ allow(File).to receive(:directory?).with('/path/to/foo-file').and_return(true)
239
+ allow(File).to receive(:directory?).with('/path/to/foo-file/file.tmp').and_return(false)
240
+ allow(File).to receive(:directory?).with('/path/to/foo').and_return(true)
241
+
242
+ allow(Dir).to receive(:entries).with('/path/to/bar-empty').and_return([])
243
+ allow(Dir).to receive(:entries).with('/path/to/foo/empty-dir').and_return(%w(. ..))
244
+ allow(Dir).to receive(:entries).with('/path/to/foo-file').and_return(%w(/path/to/foo-file/file.tmp))
245
+ allow(Dir).to receive(:entries).with('/path/to/foo').and_return(%w(. .. empty-dir))
246
+ end
247
+
248
+ it "removes empty dirs" do
249
+ # Dir.glob() discovered files
250
+ files = %w(/path/to/bar-empty /path/to/foo/empty-dir /path/to/foo-file/file.tmp /path/to/foo-file)
251
+ removed_dirs = subject.send(:remove_empty_dirs, files)
252
+
253
+ expect(removed_dirs.include?('/path/to/bar-empty')).to be_truthy
254
+ expect(removed_dirs.include?('/path/to/foo/empty-dir')).to be_truthy
255
+ expect(removed_dirs.include?('/path/to/foo-file')).to be_falsey
256
+ expect(removed_dirs.include?('/path/to/foo-file/file.tmp')).to be_falsey
257
+ expect(removed_dirs.include?('/path/to/foo')).to be_falsey
258
+ end
259
+ end
260
+
232
261
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-integration-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.5
4
+ version: 7.1.6
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-04 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -408,7 +408,7 @@ files:
408
408
  - spec/spec_helper.rb
409
409
  - spec/support/helpers.rb
410
410
  - spec/unit/outputs/sqs_spec.rb
411
- - vendor/jar-dependencies/org/logstash/plugins/integration/aws/logstash-integration-aws/7.1.5/logstash-integration-aws-7.1.5.jar
411
+ - vendor/jar-dependencies/org/logstash/plugins/integration/aws/logstash-integration-aws/7.1.6/logstash-integration-aws-7.1.6.jar
412
412
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
413
413
  licenses:
414
414
  - Apache-2.0