cantemo-portal-agent 1.1.1 → 1.2.0
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 +4 -4
- data/lib/cantemo/portal/agent/cli/commands/watch_folder.rb +1 -0
- data/lib/cantemo/portal/agent/cli/commands/watch_folders.rb +4 -3
- data/lib/cantemo/portal/agent/version.rb +1 -1
- data/lib/envoi/mam/agent.rb +16 -9
- data/lib/envoi/mam/agent/cli/commands/cantemo-agent.rb +0 -2
- data/lib/envoi/mam/agent/cli/commands/cantemo.rb +1 -1
- data/lib/envoi/mam/cantemo/agent.rb +123 -99
- data/lib/envoi/mam/cantemo/agent/watch_folder_manager.rb +75 -127
- data/lib/envoi/watch_folder_utility/watch_folder.rb +307 -0
- data/lib/envoi/watch_folder_utility/watch_folder/handler/listen.rb +28 -55
- metadata +6 -4
@@ -77,7 +77,7 @@ module Envoi
|
|
77
77
|
|
78
78
|
def initialize(args = { })
|
79
79
|
initialize_logger(args)
|
80
|
-
logger.debug { "Initializing Watch Folder. Args: #{args}" }
|
80
|
+
logger.debug { "Initializing Watch Folder Handler '#{self.class.name}'. Args: #{args}" }
|
81
81
|
|
82
82
|
@definition = args[:definition]
|
83
83
|
raise ArgumentError, "Definition is a required argument." unless definition
|
@@ -91,23 +91,7 @@ module Envoi
|
|
91
91
|
|
92
92
|
process_definition(@definition)
|
93
93
|
initialize_listener
|
94
|
-
|
95
|
-
|
96
|
-
def process_definition(work_folder_def)
|
97
|
-
# @paths = [ File.expand_path('~/watch_folders/aspera') ]
|
98
|
-
@paths = definition['paths'] || []
|
99
|
-
path = definition['path']
|
100
|
-
@paths << path if path && !@paths.include?(path)
|
101
|
-
|
102
|
-
# @quarantine_directory_path = definition['quarantine_directory_path'] || definition['quarantine_path']
|
103
|
-
@poll_interval = definition['poll_interval'] || 15
|
104
|
-
@min_stable_poll_count = definition['minimum_stable_poll_count'] || 3
|
105
|
-
@min_stable_time = definition['minimum_stable_time']
|
106
|
-
if @min_stable_time.nil? && @min_stable_poll_count && @min_stable_time
|
107
|
-
@min_stable_time = @poll_interval * @min_stable_poll_count
|
108
|
-
end
|
109
|
-
@processing_limit = definition['processing_limit'] || 10
|
110
|
-
|
94
|
+
logger.debug ( "Watch Folder Handler '#{self.class.name}' Initialized. ")
|
111
95
|
end
|
112
96
|
|
113
97
|
def initialize_logger(args = { })
|
@@ -120,11 +104,28 @@ module Envoi
|
|
120
104
|
@logger
|
121
105
|
end
|
122
106
|
|
107
|
+
def process_definition(watch_folder_def)
|
108
|
+
# @paths = [ File.expand_path('~/watch_folders/aspera') ]
|
109
|
+
@paths = watch_folder_def['paths'] || []
|
110
|
+
path = watch_folder_def['path']
|
111
|
+
@paths << path if path && !@paths.include?(path)
|
112
|
+
|
113
|
+
# @quarantine_directory_path = definition['quarantine_directory_path'] || definition['quarantine_path']
|
114
|
+
@poll_interval = watch_folder_def['poll_interval'] || 15
|
115
|
+
@min_stable_poll_count = watch_folder_def['minimum_stable_poll_count'] || 3
|
116
|
+
@min_stable_time = watch_folder_def['minimum_stable_time']
|
117
|
+
if @min_stable_time.nil? && @min_stable_poll_count && @min_stable_time
|
118
|
+
@min_stable_time = @poll_interval * @min_stable_poll_count
|
119
|
+
end
|
120
|
+
@processing_limit = watch_folder_def['processing_limit'] || 10
|
121
|
+
end
|
122
|
+
|
123
123
|
def process_deleted_path(path)
|
124
124
|
return path.each { |path| process_deleted_path(path, event_type) } if path.is_a?(Array)
|
125
125
|
logger.debug { "PATH #{:deleted} '#{path}'" }
|
126
126
|
file = known_path_map[path]
|
127
127
|
known_path_map.delete(path)
|
128
|
+
ignored_files_map.delete(path)
|
128
129
|
return unless file
|
129
130
|
file.event_type = :deleted
|
130
131
|
file.event_timestamp = Time.now
|
@@ -144,11 +145,6 @@ module Envoi
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def initialize_listener(args = { })
|
147
|
-
# @directories = directories.map do |directory|
|
148
|
-
# Pathname.new(directory.to_s).realpath
|
149
|
-
# end
|
150
|
-
|
151
|
-
|
152
148
|
@listener = ::Listen.to(*paths, {}) do |m, a, r|
|
153
149
|
if !r.empty?
|
154
150
|
log "#{r.length} file(s) removed."
|
@@ -166,10 +162,15 @@ module Envoi
|
|
166
162
|
end
|
167
163
|
|
168
164
|
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Listen doesn't perform an initial inventory by default so this method will pick up
|
168
|
+
# any files that are already present
|
169
|
+
def perform_initial_inventory
|
169
170
|
_config = @listener.instance_variable_get(:@backend).instance_variable_get(:@adapter).config
|
171
|
+
# change_config = ::Listen::Change::Config.new(_config.queue, _config.silencer)
|
170
172
|
|
171
173
|
_snapshots ||= {}
|
172
|
-
# change_config = ::Listen::Change::Config.new(_config.queue, _config.silencer)
|
173
174
|
_config.directories.each do |dir|
|
174
175
|
record = ::Listen::Record.new(dir)
|
175
176
|
record.build
|
@@ -185,55 +186,27 @@ module Envoi
|
|
185
186
|
# pp _snapshots
|
186
187
|
end
|
187
188
|
|
188
|
-
def log(message)
|
189
|
-
puts "#{Time.now} #{message}"
|
190
|
-
end
|
191
|
-
|
192
189
|
def add_to_ignore(file)
|
193
190
|
@ignored_files_map[file.path] = file
|
194
191
|
end
|
195
192
|
|
196
|
-
#
|
197
|
-
# full_file_path = file[:path]
|
198
|
-
# logger.info { "Processing File Path: #{full_file_path}..." }
|
199
|
-
# if true
|
200
|
-
# FileUtils.rm full_file_path
|
201
|
-
# else
|
202
|
-
# if quarantine_directory_path
|
203
|
-
# FileUtils.mv full_file_path, quarantine_directory_path
|
204
|
-
# end
|
205
|
-
# end
|
206
|
-
# end
|
207
|
-
|
193
|
+
# Really this is just for debugging as polling isn't used to determine file stability
|
208
194
|
def poll(options = { })
|
209
195
|
should_increment_counter = options.fetch(:should_increment_counter, true)
|
210
196
|
|
211
197
|
@previous_poll_time = @last_poll_time
|
212
198
|
@last_poll_time = Time.now
|
199
|
+
|
213
200
|
lock.synchronize do
|
214
201
|
@known_path_map.each do |fp, f|
|
215
202
|
next if f.ignore?
|
216
203
|
next unless f.exist?
|
217
204
|
|
218
205
|
logger.debug { "Incrementing Stable Stats: #{f.summary}" }
|
219
|
-
|
220
|
-
f.last_poll_time ||= Time.now
|
206
|
+
f.last_poll_time = Time.now
|
221
207
|
f[:stable_poll_count] += 1 if should_increment_counter
|
222
|
-
|
223
|
-
#
|
224
|
-
# if @min_stable_time
|
225
|
-
# if (Time.now - f.event_timestamp) >= @min_stable_time
|
226
|
-
# is_stable = true
|
227
|
-
# end
|
228
|
-
# else
|
229
|
-
# if f[:stable_poll_count] >= @min_stable_poll_count
|
230
|
-
# is_stable = true
|
231
|
-
# # handle_stable_file(f)
|
232
|
-
# end
|
233
|
-
# end
|
234
208
|
end
|
235
209
|
end
|
236
|
-
stable_files
|
237
210
|
end
|
238
211
|
|
239
212
|
def stable_files
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cantemo-portal-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Whitson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asperalm
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk-s3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- exe/cantemo-portal-agent
|
148
148
|
- lib/cantemo/portal/agent.rb
|
149
149
|
- lib/cantemo/portal/agent/WatchFolderUtility/foreman.rb
|
150
|
+
- lib/cantemo/portal/agent/cli/commands/watch_folder.rb
|
150
151
|
- lib/cantemo/portal/agent/cli/commands/watch_folders-working.rb
|
151
152
|
- lib/cantemo/portal/agent/cli/commands/watch_folders.rb
|
152
153
|
- lib/cantemo/portal/agent/version.rb
|
@@ -188,6 +189,7 @@ files:
|
|
188
189
|
- lib/envoi/mam/vdms/agent.rb
|
189
190
|
- lib/envoi/mam/vidispine/agent.rb
|
190
191
|
- lib/envoi/mam/wiredrive/agent.rb
|
192
|
+
- lib/envoi/watch_folder_utility/watch_folder.rb
|
191
193
|
- lib/envoi/watch_folder_utility/watch_folder/handler/listen.rb
|
192
194
|
homepage: http://www.github.com/XPlatform-Consulting/envoi-mam-agent
|
193
195
|
licenses:
|