rest-ftp-daemon 0.423.3 → 0.424.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +30 -0
- data/Gemfile.lock +9 -8
- data/README.md +1 -5
- data/bin/rest-ftp-daemon +11 -5
- data/defaults.yml +16 -10
- data/lib/rest-ftp-daemon.rb +14 -10
- data/lib/rest-ftp-daemon/api/jobs.rb +42 -18
- data/lib/rest-ftp-daemon/api/root.rb +5 -1
- data/lib/rest-ftp-daemon/constants.rb +0 -1
- data/lib/rest-ftp-daemon/{api/entities → entities}/job.rb +0 -0
- data/lib/rest-ftp-daemon/{api/entities → entities}/location.rb +0 -0
- data/lib/rest-ftp-daemon/{api/entities → entities}/options.rb +0 -0
- data/lib/rest-ftp-daemon/exceptions.rb +1 -0
- data/lib/rest-ftp-daemon/helpers/views.rb +7 -2
- data/lib/rest-ftp-daemon/initialize.rb +3 -0
- data/lib/rest-ftp-daemon/job.rb +3 -0
- data/lib/rest-ftp-daemon/jobs/transfer.rb +4 -4
- data/lib/rest-ftp-daemon/location.rb +5 -0
- data/lib/rest-ftp-daemon/remote/base.rb +76 -0
- data/lib/rest-ftp-daemon/remote/ftp.rb +144 -0
- data/lib/rest-ftp-daemon/remote/s3.rb +78 -0
- data/lib/rest-ftp-daemon/remote/sftp.rb +147 -0
- data/lib/rest-ftp-daemon/static/images/feature_reload.png +0 -0
- data/lib/rest-ftp-daemon/static/images/feature_rollbar.png +0 -0
- data/lib/rest-ftp-daemon/static/swagger/css/print.css +2 -2
- data/lib/rest-ftp-daemon/static/swagger/css/screen.css +2 -2
- data/lib/rest-ftp-daemon/views/dashboard_footer.haml +3 -2
- data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +3 -3
- data/lib/rest-ftp-daemon/views/dashboard_table.haml +5 -4
- data/lib/rest-ftp-daemon/workers/reporter.rb +2 -2
- data/rest-ftp-daemon.gemspec +4 -7
- metadata +28 -25
- data/lib/rest-ftp-daemon/remote.rb +0 -74
- data/lib/rest-ftp-daemon/remote_ftp.rb +0 -142
- data/lib/rest-ftp-daemon/remote_s3.rb +0 -76
- data/lib/rest-ftp-daemon/remote_sftp.rb +0 -145
Binary file
|
Binary file
|
@@ -508,7 +508,7 @@
|
|
508
508
|
clear: both;
|
509
509
|
}
|
510
510
|
.swagger-section .swagger-ui-wrap .body-textarea {
|
511
|
-
width:
|
511
|
+
width: 200px;
|
512
512
|
height: 100px;
|
513
513
|
border: 1px solid #aaa;
|
514
514
|
}
|
@@ -534,7 +534,7 @@
|
|
534
534
|
font-weight: bold!important;
|
535
535
|
}
|
536
536
|
.swagger-section .swagger-ui-wrap input.parameter {
|
537
|
-
width:
|
537
|
+
width: 200px;
|
538
538
|
border: 1px solid #aaa;
|
539
539
|
}
|
540
540
|
.swagger-section .swagger-ui-wrap h1 {
|
@@ -508,7 +508,7 @@
|
|
508
508
|
clear: both;
|
509
509
|
}
|
510
510
|
.swagger-section .swagger-ui-wrap .body-textarea {
|
511
|
-
width:
|
511
|
+
width: 200px;
|
512
512
|
height: 100px;
|
513
513
|
border: 1px solid #aaa;
|
514
514
|
}
|
@@ -534,7 +534,7 @@
|
|
534
534
|
font-weight: bold!important;
|
535
535
|
}
|
536
536
|
.swagger-section .swagger-ui-wrap input.parameter {
|
537
|
-
width:
|
537
|
+
width: 200px;
|
538
538
|
border: 1px solid #aaa;
|
539
539
|
}
|
540
540
|
.swagger-section .swagger-ui-wrap h1 {
|
@@ -25,8 +25,9 @@
|
|
25
25
|
|
26
26
|
.btn-group.btn-group-sm
|
27
27
|
.btn.btn-default.btn-info Features
|
28
|
-
= dashboard_feature :reload, Conf[:allow_reload], "
|
29
|
-
= dashboard_feature :newrelic, Conf.
|
28
|
+
= dashboard_feature :reload, Conf[:allow_reload], "ACTIVE (config is hot-reloadable)", "changes at startup only"
|
29
|
+
= dashboard_feature :newrelic, Conf.feature?(:newrelic), "ACTIVE (license found)", "disabled"
|
30
|
+
= dashboard_feature :rollbar, Conf.feature?(:rollbar), "ACTIVE (token found)", "disabled"
|
30
31
|
|
31
32
|
.btn-group.btn-group-sm
|
32
33
|
.btn.btn-default.btn-info IP
|
@@ -30,18 +30,18 @@
|
|
30
30
|
%thead
|
31
31
|
%tr
|
32
32
|
%th ID
|
33
|
+
%th T
|
33
34
|
%th pool
|
35
|
+
%th queued
|
34
36
|
%th label
|
35
|
-
%th type
|
36
37
|
%th
|
37
38
|
%th source
|
38
39
|
%th
|
39
40
|
%th target
|
40
|
-
%th queued
|
41
41
|
%th.error status
|
42
42
|
%th{"min-width" => 120} detail
|
43
43
|
%th.text-right size
|
44
|
-
%th.text-right
|
44
|
+
%th.text-right rate
|
45
45
|
%th{title: "Worker ID"} W
|
46
46
|
%th{title: "Priority"} P
|
47
47
|
%th{title: "Runs count"} R
|
@@ -19,15 +19,18 @@
|
|
19
19
|
- trclass = "warning"
|
20
20
|
|
21
21
|
%tr{class: trclass.to_s}
|
22
|
+
|
22
23
|
%td
|
23
24
|
%a{href: dashboard_job_url(job)}
|
24
25
|
%b= job.id
|
25
26
|
|
27
|
+
%td= job_type job
|
28
|
+
|
26
29
|
%td= job.pool
|
27
30
|
|
28
|
-
%td= job.
|
31
|
+
%td= datetime_short(job.queued_at)
|
29
32
|
|
30
|
-
%td=
|
33
|
+
%td= job.label
|
31
34
|
|
32
35
|
%td.text-right= location_label job.source_uri
|
33
36
|
%td= token_highlight job.source
|
@@ -35,8 +38,6 @@
|
|
35
38
|
%td.text-right= location_label job.target_uri
|
36
39
|
%td= token_highlight job.target
|
37
40
|
|
38
|
-
%td= datetime_short(job.queued_at)
|
39
|
-
|
40
41
|
%td
|
41
42
|
%span.push-status
|
42
43
|
= job.status
|
@@ -10,7 +10,7 @@ module RestFtpDaemon
|
|
10
10
|
config_section :reporter
|
11
11
|
|
12
12
|
# Other configuration options
|
13
|
-
@report_newrelic = Conf.
|
13
|
+
@report_newrelic = Conf.feature?(:newrelic)
|
14
14
|
|
15
15
|
# Check that everything is OK
|
16
16
|
return "invalid timer" unless @config[:timer].to_i > 0
|
@@ -35,7 +35,7 @@ module RestFtpDaemon
|
|
35
35
|
|
36
36
|
def do_metrics
|
37
37
|
# What metrics to report?
|
38
|
-
report_newrelic = Conf.
|
38
|
+
report_newrelic = Conf.feature?(:newrelic)
|
39
39
|
|
40
40
|
# Get common metrics and dump them to logs
|
41
41
|
log_debug "begin metrics sample"
|
data/rest-ftp-daemon.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
|
4
4
|
# Project version
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.424.0"
|
6
6
|
|
7
7
|
# Project description
|
8
8
|
spec.name = "rest-ftp-daemon"
|
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.licenses = ["MIT"]
|
15
15
|
spec.date = Time.now.strftime("%Y-%m-%d")
|
16
16
|
|
17
|
-
|
18
17
|
# List files and executables
|
19
18
|
spec.files = `git ls-files -z`.
|
20
19
|
split("\x0").
|
@@ -23,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
23
22
|
spec.require_paths = ["lib"]
|
24
23
|
spec.required_ruby_version = ">= 2.2.2"
|
25
24
|
|
26
|
-
|
27
25
|
# Development dependencies
|
28
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
29
27
|
spec.add_development_dependency "rake"
|
@@ -33,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
33
31
|
spec.add_development_dependency "http"
|
34
32
|
|
35
33
|
# Runtime dependencies
|
36
|
-
spec.add_runtime_dependency "bmc-daemon-lib", "~> 0.3.
|
34
|
+
spec.add_runtime_dependency "bmc-daemon-lib", "~> 0.3.8"
|
37
35
|
spec.add_runtime_dependency "json", "~> 1.8"
|
38
36
|
spec.add_runtime_dependency "thin", "~> 1.7"
|
39
37
|
spec.add_runtime_dependency "activesupport", "~> 4.2"
|
@@ -44,20 +42,19 @@ Gem::Specification.new do |spec|
|
|
44
42
|
spec.add_runtime_dependency "grape-swagger-entity"
|
45
43
|
spec.add_runtime_dependency "grape-swagger-representable"
|
46
44
|
|
47
|
-
spec.add_runtime_dependency "settingslogic"
|
48
45
|
spec.add_runtime_dependency "rest-client", "~> 1.8"
|
49
46
|
spec.add_runtime_dependency "api-auth"
|
50
47
|
spec.add_runtime_dependency "haml"
|
51
48
|
spec.add_runtime_dependency "facter"
|
52
49
|
spec.add_runtime_dependency "sys-cpu"
|
53
50
|
spec.add_runtime_dependency "get_process_mem"
|
54
|
-
spec.add_runtime_dependency "newrelic_rpm"
|
55
51
|
|
52
|
+
spec.add_runtime_dependency "newrelic_rpm"
|
53
|
+
spec.add_runtime_dependency "rollbar"
|
56
54
|
|
57
55
|
spec.add_runtime_dependency "net-sftp"
|
58
56
|
spec.add_runtime_dependency "double-bag-ftps"
|
59
57
|
spec.add_runtime_dependency "aws-sdk-resources", '~> 2'
|
60
|
-
|
61
58
|
spec.add_runtime_dependency "streamio-ffmpeg"
|
62
59
|
|
63
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-ftp-daemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.424.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno MEDICI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.3.
|
103
|
+
version: 0.3.8
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.3.
|
110
|
+
version: 0.3.8
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,20 +220,6 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: settingslogic
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :runtime
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
223
|
- !ruby/object:Gem::Dependency
|
238
224
|
name: rest-client
|
239
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,6 +318,20 @@ dependencies:
|
|
332
318
|
- - ">="
|
333
319
|
- !ruby/object:Gem::Version
|
334
320
|
version: '0'
|
321
|
+
- !ruby/object:Gem::Dependency
|
322
|
+
name: rollbar
|
323
|
+
requirement: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - ">="
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '0'
|
328
|
+
type: :runtime
|
329
|
+
prerelease: false
|
330
|
+
version_requirements: !ruby/object:Gem::Requirement
|
331
|
+
requirements:
|
332
|
+
- - ">="
|
333
|
+
- !ruby/object:Gem::Version
|
334
|
+
version: '0'
|
335
335
|
- !ruby/object:Gem::Dependency
|
336
336
|
name: net-sftp
|
337
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -396,6 +396,7 @@ executables:
|
|
396
396
|
extensions: []
|
397
397
|
extra_rdoc_files: []
|
398
398
|
files:
|
399
|
+
- ".codeclimate.yml"
|
399
400
|
- ".gitignore"
|
400
401
|
- ".rspec"
|
401
402
|
- ".rubocop.yml"
|
@@ -412,9 +413,6 @@ files:
|
|
412
413
|
- lib/rest-ftp-daemon/api/config.rb
|
413
414
|
- lib/rest-ftp-daemon/api/dashboard.rb
|
414
415
|
- lib/rest-ftp-daemon/api/debug.rb
|
415
|
-
- lib/rest-ftp-daemon/api/entities/job.rb
|
416
|
-
- lib/rest-ftp-daemon/api/entities/location.rb
|
417
|
-
- lib/rest-ftp-daemon/api/entities/options.rb
|
418
416
|
- lib/rest-ftp-daemon/api/jobs.rb
|
419
417
|
- lib/rest-ftp-daemon/api/root-real.rb
|
420
418
|
- lib/rest-ftp-daemon/api/root-test.rb
|
@@ -422,10 +420,14 @@ files:
|
|
422
420
|
- lib/rest-ftp-daemon/api/status.rb
|
423
421
|
- lib/rest-ftp-daemon/constants.rb
|
424
422
|
- lib/rest-ftp-daemon/counters.rb
|
423
|
+
- lib/rest-ftp-daemon/entities/job.rb
|
424
|
+
- lib/rest-ftp-daemon/entities/location.rb
|
425
|
+
- lib/rest-ftp-daemon/entities/options.rb
|
425
426
|
- lib/rest-ftp-daemon/exceptions.rb
|
426
427
|
- lib/rest-ftp-daemon/helpers/api.rb
|
427
428
|
- lib/rest-ftp-daemon/helpers/common.rb
|
428
429
|
- lib/rest-ftp-daemon/helpers/views.rb
|
430
|
+
- lib/rest-ftp-daemon/initialize.rb
|
429
431
|
- lib/rest-ftp-daemon/job.rb
|
430
432
|
- lib/rest-ftp-daemon/job_queue.rb
|
431
433
|
- lib/rest-ftp-daemon/jobs/dummy.rb
|
@@ -437,10 +439,10 @@ files:
|
|
437
439
|
- lib/rest-ftp-daemon/metrics.rb
|
438
440
|
- lib/rest-ftp-daemon/notification.rb
|
439
441
|
- lib/rest-ftp-daemon/paginate.rb
|
440
|
-
- lib/rest-ftp-daemon/remote.rb
|
441
|
-
- lib/rest-ftp-daemon/
|
442
|
-
- lib/rest-ftp-daemon/
|
443
|
-
- lib/rest-ftp-daemon/
|
442
|
+
- lib/rest-ftp-daemon/remote/base.rb
|
443
|
+
- lib/rest-ftp-daemon/remote/ftp.rb
|
444
|
+
- lib/rest-ftp-daemon/remote/s3.rb
|
445
|
+
- lib/rest-ftp-daemon/remote/sftp.rb
|
444
446
|
- lib/rest-ftp-daemon/static/config.json
|
445
447
|
- lib/rest-ftp-daemon/static/css/bootstrap.min.css
|
446
448
|
- lib/rest-ftp-daemon/static/css/bootstrap.old.css
|
@@ -452,6 +454,7 @@ files:
|
|
452
454
|
- lib/rest-ftp-daemon/static/fonts/glyphicons-halflings-regular.woff2
|
453
455
|
- lib/rest-ftp-daemon/static/images/feature_newrelic.png
|
454
456
|
- lib/rest-ftp-daemon/static/images/feature_reload.png
|
457
|
+
- lib/rest-ftp-daemon/static/images/feature_rollbar.png
|
455
458
|
- lib/rest-ftp-daemon/static/swagger.html
|
456
459
|
- lib/rest-ftp-daemon/static/swagger/css/print.css
|
457
460
|
- lib/rest-ftp-daemon/static/swagger/css/reset.css
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# Handles transfers for Job class
|
2
|
-
module RestFtpDaemon
|
3
|
-
class Remote
|
4
|
-
include BmcDaemonLib::LoggerHelper
|
5
|
-
|
6
|
-
# Class options
|
7
|
-
attr_reader :logger
|
8
|
-
attr_reader :log_prefix
|
9
|
-
attr_accessor :job
|
10
|
-
|
11
|
-
# Delegate set_info info to Job
|
12
|
-
delegate :set_info, to: :job
|
13
|
-
|
14
|
-
def initialize target, log_prefix, debug = false, ftpes = false
|
15
|
-
# Init
|
16
|
-
@target = target
|
17
|
-
@ftpes = ftpes
|
18
|
-
@debug = !!debug
|
19
|
-
|
20
|
-
# Build and empty job to protect set_info delegation
|
21
|
-
@job = Job.new(nil, {})
|
22
|
-
|
23
|
-
# Logger
|
24
|
-
@log_prefix = log_prefix || {}
|
25
|
-
@logger = BmcDaemonLib::LoggerPool.instance.get :transfer
|
26
|
-
|
27
|
-
# Annnounce object
|
28
|
-
log_info "Remote.initialize debug[#{debug}] target[#{target.path}] "
|
29
|
-
|
30
|
-
# Prepare real object
|
31
|
-
prepare
|
32
|
-
end
|
33
|
-
|
34
|
-
def prepare
|
35
|
-
end
|
36
|
-
|
37
|
-
def connect
|
38
|
-
# Debug mode ?
|
39
|
-
return unless @debug
|
40
|
-
puts
|
41
|
-
puts "-------------------- SESSION STARTING -------------------------"
|
42
|
-
puts "class\t #{myname}"
|
43
|
-
puts "host\t #{@target.host}"
|
44
|
-
puts "user\t #{@target.user}"
|
45
|
-
puts "port\t #{@target.port}"
|
46
|
-
puts "---------------------------------------------------------------"
|
47
|
-
end
|
48
|
-
|
49
|
-
def chdir_or_create directory, mkdir = false
|
50
|
-
end
|
51
|
-
|
52
|
-
def remove! target
|
53
|
-
end
|
54
|
-
|
55
|
-
def close
|
56
|
-
# Debug mode ?
|
57
|
-
return unless @debug
|
58
|
-
puts "-------------------- SESSION CLOSING --------------------------"
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def extract_parent path
|
64
|
-
return unless path.is_a? String
|
65
|
-
m = path.match(/^(.*)\/([^\/]+)\/?$/)
|
66
|
-
return m[1], m[2] unless m.nil?
|
67
|
-
end
|
68
|
-
|
69
|
-
def myname
|
70
|
-
self.class.to_s
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
require "net/ftp"
|
2
|
-
require "double_bag_ftps"
|
3
|
-
|
4
|
-
# Handle FTP and FTPeS transfers for Remote class
|
5
|
-
module RestFtpDaemon
|
6
|
-
class RemoteFTP < Remote
|
7
|
-
|
8
|
-
# Class options
|
9
|
-
attr_reader :ftp
|
10
|
-
|
11
|
-
def prepare
|
12
|
-
# Create FTP object
|
13
|
-
if @ftpes
|
14
|
-
prepare_ftpes
|
15
|
-
else
|
16
|
-
prepare_ftp
|
17
|
-
end
|
18
|
-
@ftp.passive = true
|
19
|
-
@ftp.debug_mode = @debug
|
20
|
-
|
21
|
-
# Config
|
22
|
-
@chunk_size = DEFAULT_FTP_CHUNK.to_i * 1024
|
23
|
-
|
24
|
-
# Announce object
|
25
|
-
log_debug "RemoteFTP.prepare chunk_size:#{@chunk_size}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def connect
|
29
|
-
super
|
30
|
-
|
31
|
-
# Connect remote server
|
32
|
-
@ftp.connect @target.host, @target.port
|
33
|
-
@ftp.login @target.user, @target.password
|
34
|
-
end
|
35
|
-
|
36
|
-
def present? target
|
37
|
-
size = @ftp.size target.path
|
38
|
-
log_debug "RemoteFTP.present? [#{target.name}]"
|
39
|
-
|
40
|
-
rescue Net::FTPPermError
|
41
|
-
return false
|
42
|
-
else
|
43
|
-
return size
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove! target
|
47
|
-
@ftp.delete target.path
|
48
|
-
rescue Net::FTPPermError
|
49
|
-
log_debug "RemoteFTP.remove! [#{target.name}] not found"
|
50
|
-
else
|
51
|
-
log_debug "RemoteFTP.remove! [#{target.name}] removed"
|
52
|
-
end
|
53
|
-
|
54
|
-
def mkdir directory
|
55
|
-
log_debug "RemoteFTP.mkdir [#{directory}]"
|
56
|
-
@ftp.mkdir directory
|
57
|
-
|
58
|
-
rescue StandardError => ex
|
59
|
-
raise TargetPermissionError, ex.message
|
60
|
-
end
|
61
|
-
|
62
|
-
def chdir_or_create directory, mkdir = false
|
63
|
-
# Init, extract my parent name and my own name
|
64
|
-
log_debug "RemoteFTP.chdir_or_create mkdir[#{mkdir}] dir[#{directory}]"
|
65
|
-
parent, current = extract_parent(directory)
|
66
|
-
|
67
|
-
#dirname, _current = extract_parent(directory)
|
68
|
-
|
69
|
-
|
70
|
-
# Access this directory
|
71
|
-
begin
|
72
|
-
@ftp.chdir "/#{directory}"
|
73
|
-
|
74
|
-
rescue Net::FTPPermError => _e
|
75
|
-
# If not allowed to create path, that's over, we're stuck
|
76
|
-
return false unless mkdir
|
77
|
-
chdir_or_create parent, mkdir
|
78
|
-
|
79
|
-
# Now I was able to chdir into my parent, create the current directory
|
80
|
-
mkdir current
|
81
|
-
|
82
|
-
# Finally retry the chdir
|
83
|
-
retry
|
84
|
-
else
|
85
|
-
return true
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def upload source, target, use_temp_name = false, &callback
|
90
|
-
# Push init
|
91
|
-
raise RestFtpDaemon::AssertionFailed, "upload/ftp" if @ftp.nil?
|
92
|
-
|
93
|
-
# Temp file if needed
|
94
|
-
dest = target.clone
|
95
|
-
if use_temp_name
|
96
|
-
dest.generate_temp_name!
|
97
|
-
end
|
98
|
-
|
99
|
-
# Move to the directory
|
100
|
-
log_debug "RemoteFTP.upload chdir [#{dest.dir}]"
|
101
|
-
@ftp.chdir "/#{dest.dir}"
|
102
|
-
|
103
|
-
# Do the transfer
|
104
|
-
log_debug "RemoteFTP.upload putbinaryfile [#{dest.name}]"
|
105
|
-
@ftp.putbinaryfile source.path, dest.name, @chunk_size do |data|
|
106
|
-
# Update job status after this block transfer
|
107
|
-
yield data.bytesize, dest.name
|
108
|
-
end
|
109
|
-
|
110
|
-
# Move the file back to its original name
|
111
|
-
if use_temp_name
|
112
|
-
log_debug "RemoteFTP.upload rename [#{dest.name}] > [#{target.name}]"
|
113
|
-
@ftp.rename dest.name, target.name
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def close
|
118
|
-
# Close init
|
119
|
-
super
|
120
|
-
|
121
|
-
# Close FTP connexion and free up memory
|
122
|
-
@ftp.close
|
123
|
-
end
|
124
|
-
|
125
|
-
def connected?
|
126
|
-
!@ftp.welcome.nil?
|
127
|
-
end
|
128
|
-
|
129
|
-
private
|
130
|
-
|
131
|
-
def prepare_ftp
|
132
|
-
@ftp = Net::FTP.new
|
133
|
-
end
|
134
|
-
|
135
|
-
def prepare_ftpes
|
136
|
-
@ftp = DoubleBagFTPS.new
|
137
|
-
@ftp.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
138
|
-
@ftp.ftps_mode = DoubleBagFTPS::EXPLICIT
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
end
|