photocopier 1.3.0.pre → 1.3.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/photocopier/ftp/session.rb +12 -2
- data/lib/photocopier/ftp.rb +19 -12
- data/lib/photocopier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d09179ce249ba612eff1014e10d24e16e7bbb73
|
4
|
+
data.tar.gz: b631249fc13d03e650aa345bb4e134f4e30e384d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd9347e0a828d143332be5990b1c949053218470d7a97fc23f73cbf41a48db95baeb0a0a52249802aa89fe26cafcabf56008337d6d2f8138afe736dd7bf8b4f
|
7
|
+
data.tar.gz: b10c5a142ecafb3e3690efada776cdc4b9bb83c26bf3e9e0e1c76946e3ef2e31afd8594d63607b2ad120de09ba611ab3a011e2e90ec0575bbac3538cbeca49c3
|
@@ -5,9 +5,19 @@ module Photocopier
|
|
5
5
|
@scheme = options[:scheme]
|
6
6
|
|
7
7
|
if sftp?
|
8
|
-
@session = Net::SFTP.start(
|
8
|
+
@session = Net::SFTP.start(
|
9
|
+
options[:host],
|
10
|
+
options[:user],
|
11
|
+
password: options[:password],
|
12
|
+
port: options[:port] || 22
|
13
|
+
)
|
9
14
|
else
|
10
|
-
@session = Net::FTP.open(
|
15
|
+
@session = Net::FTP.open(
|
16
|
+
options[:host],
|
17
|
+
username: options[:user],
|
18
|
+
password: options[:password],
|
19
|
+
port: options[:port] || 21
|
20
|
+
)
|
11
21
|
@session.passive = options[:passive] if options.key?(:passive)
|
12
22
|
end
|
13
23
|
end
|
data/lib/photocopier/ftp.rb
CHANGED
@@ -22,11 +22,11 @@ module Photocopier
|
|
22
22
|
|
23
23
|
def get_directory(remote_path, local_path, exclude = [])
|
24
24
|
FileUtils.mkdir_p(local_path)
|
25
|
-
lftp(local_path, remote_path, false, exclude)
|
25
|
+
lftp(local_path, remote_path, false, exclude, options[:port])
|
26
26
|
end
|
27
27
|
|
28
28
|
def put_directory(local_path, remote_path, exclude = [])
|
29
|
-
lftp(local_path, remote_path, true, exclude)
|
29
|
+
lftp(local_path, remote_path, true, exclude, options[:port])
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -35,20 +35,26 @@ module Photocopier
|
|
35
35
|
@session ||= Session.new(options)
|
36
36
|
end
|
37
37
|
|
38
|
-
def lftp(local, remote, reverse, exclude)
|
38
|
+
def lftp(local, remote, reverse, exclude, port = nil)
|
39
|
+
if port.nil? && options[:scheme] == 'sftp'
|
40
|
+
port = 22
|
41
|
+
elsif port.nil?
|
42
|
+
port = 21
|
43
|
+
end
|
44
|
+
|
39
45
|
remote = Shellwords.escape(remote)
|
40
46
|
local = Shellwords.escape(local)
|
41
47
|
command = [
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
"set ftp:list-options -a",
|
49
|
+
"set cmd:fail-exit true",
|
50
|
+
"open #{remote_ftp_url}",
|
51
|
+
"find -d 1 #{remote} || mkdir -p #{remote}",
|
52
|
+
"lcd #{local}",
|
53
|
+
"cd #{remote}",
|
54
|
+
lftp_mirror_arguments(reverse, exclude)
|
49
55
|
].join("; ")
|
50
56
|
|
51
|
-
run "lftp -c '#{command}'"
|
57
|
+
run "lftp -c '#{command}' -p #{port}"
|
52
58
|
end
|
53
59
|
|
54
60
|
def remote_ftp_url
|
@@ -64,7 +70,8 @@ module Photocopier
|
|
64
70
|
end
|
65
71
|
|
66
72
|
def lftp_mirror_arguments(reverse, exclude = [])
|
67
|
-
mirror = "mirror --delete --use-cache --verbose
|
73
|
+
mirror = "mirror --delete --use-cache --verbose" \
|
74
|
+
" --no-perms --allow-suid --no-umask --parallel=5"
|
68
75
|
mirror << " --reverse --dereference" if reverse
|
69
76
|
exclude.each do |glob|
|
70
77
|
mirror << " --exclude-glob #{glob}" # NOTE do not use Shellwords.escape here
|
data/lib/photocopier/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photocopier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-07-
|
13
|
+
date: 2018-07-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|