virus_scan_service 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf6e55eaf62680d1be8e694764b1605bbaac01c
4
- data.tar.gz: 460699cfe3f4ce7c704713e2040616da23bd9662
3
+ metadata.gz: 1c57649e24aa21b5e7cbf130bafe516fb73a8b53
4
+ data.tar.gz: 84d882db0f9cbbe6ac838e3d54db99910565ad62
5
5
  SHA512:
6
- metadata.gz: a1c3f1286168df5211767b88e439c2fdc5cfd345a22ae43deb48af8cc50eb760fe07082516e3dab69ccfd74bce75e50d41db48716f581a8841b47d493852d97e
7
- data.tar.gz: 0d21601261ad671eae88513d8e5fd88d7945daba6faf3793c18bf7733650a92d72d60776c5db49070995b51eaa44ed1258cc2eec6005b3bcf8363ab23ab04b53
6
+ metadata.gz: 8b8bae196bbe4b932d29be63416f34ddebf91228dc571a8fd82712edd709ab89a070ca4914a911245f59a6c834c627135ebae8847f974b5129429d80f628fb7b
7
+ data.tar.gz: e93715bc824c704f765dd9ee4da8a804adb29f3cc037710db4cf96950b7304b4742b341a5b2d848e4bb698e8c9b5dfcfb661dc9f5244231e608be821619dcb0e
@@ -1,5 +1,6 @@
1
1
  require_relative 'kaspersky_runner/linux_executor'
2
2
  require_relative 'kaspersky_runner/windows_executor'
3
+ require 'fileutils'
3
4
 
4
5
  module VirusScanService
5
6
  class KasperskyRunner
@@ -23,12 +24,12 @@ module VirusScanService
23
24
  begin
24
25
  pull_file
25
26
  begin
26
- ensure_no_scan_log_exist
27
+ empty_scan_log
27
28
  scan_file
28
29
  set_result
29
30
  ensure
30
31
  remove_file
31
- archive_scan_log if File.exist?(scan_log_path)
32
+ archive_scan_log if File.size?(scan_log_path) # Exists & non-empty
32
33
  end
33
34
  rescue URI::InvalidURIError, RequestNotSuccessful
34
35
  set_result_download_error
@@ -45,7 +46,7 @@ module VirusScanService
45
46
  .new('/tmp')
46
47
  .join('scans')
47
48
  .tap do |path|
48
- FileUtils.mkdir_p(path)
49
+ ::FileUtils.mkdir_p(path)
49
50
  end
50
51
  end
51
52
 
@@ -54,14 +55,14 @@ module VirusScanService
54
55
  .new('/tmp')
55
56
  .join('scans')
56
57
  .tap do |path|
57
- FileUtils.mkdir_p(path)
58
+ ::FileUtils.mkdir_p(path)
58
59
  end
59
60
  end
60
61
 
61
62
  private
62
63
  def archive_scan_log
63
64
  archive_name = "#{File.basename(scan_log_path.to_s, '.*')}_#{timestamp_builder.call}.log"
64
- FileUtils.mv(scan_log_path, archive_folder.join(archive_name))
65
+ ::FileUtils.mv(scan_log_path, archive_folder.join(archive_name))
65
66
  end
66
67
 
67
68
  def remove_file
@@ -76,15 +77,15 @@ module VirusScanService
76
77
  #
77
78
  # if File.exist?(scan_folder.join(filename))
78
79
  #
79
- # wont help to determin if file was removed by kaspersky
80
+ # won't help to determine if file was removed by kaspersky
80
81
  #
81
82
  # That's why this captures if exception matches Permission deny @ unlink_internal
82
83
  raise e unless e.to_s.match('unlink_internal')
83
84
  end
84
85
  end
85
86
 
86
- def ensure_no_scan_log_exist
87
- FileUtils.rm scan_log_path if File.exist?(scan_log_path)
87
+ def empty_scan_log
88
+ File.open(scan_log_path, 'w') {}
88
89
  end
89
90
 
90
91
  def set_result
@@ -1,3 +1,3 @@
1
1
  module VirusScanService
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -69,7 +69,7 @@ RSpec.describe VirusScanService::KasperskyRunner do
69
69
  end
70
70
 
71
71
  before do
72
- expect(runner).to receive(:ensure_no_scan_log_exist).and_call_original
72
+ expect(runner).to receive(:empty_scan_log).and_call_original
73
73
  end
74
74
 
75
75
  context '' do
@@ -155,11 +155,11 @@ RSpec.describe VirusScanService::KasperskyRunner do
155
155
  end
156
156
  end
157
157
 
158
- describe 'private #ensure_no_scan_log_exist' do
158
+ describe 'private #empty_scan_log' do
159
159
  it 'should existing scan log before scan begin' do
160
160
  FileUtils.cp(scan_log, 'spec/tmp/kaspersky_test.log') # pre-existing scan
161
- runner.send(:ensure_no_scan_log_exist)
162
- expect(File.exist?('spec/tmp/kaspersky_test.log')).to be false
161
+ runner.send(:empty_scan_log)
162
+ expect(File.size('spec/tmp/kaspersky_test.log')).to eq 0
163
163
  end
164
164
  end
165
165
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virus_scan_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler