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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7c9e146b3e1470970f2f95815ef0bac16517ee2
4
- data.tar.gz: b9a43d8c3b696e6b755f8888d6286ad8512bdceb
3
+ metadata.gz: 8d09179ce249ba612eff1014e10d24e16e7bbb73
4
+ data.tar.gz: b631249fc13d03e650aa345bb4e134f4e30e384d
5
5
  SHA512:
6
- metadata.gz: 30e977409752782228a0b4dd73d496b5308236a4770c752efe46b3b88ec2785bbce9f808e1ac06ae9fece98719d9a263874ef1ad9d42471ec092a32be29d6cd6
7
- data.tar.gz: 66c2b1d04a8715715262875d8c317eaff2a3d2b638a95083a08afff4af826b30d4e4a3aaf177197c07c69556be6af5cdf00fff0dfaabe17a74d4fecb5d39d126
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(options[:host], options[:user], password: options[:password])
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(options[:host], options[:user], options[:password])
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
@@ -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
- "set ftp:list-options -a",
43
- "set cmd:fail-exit true",
44
- "open #{remote_ftp_url}",
45
- "find -d 1 #{remote} || mkdir -p #{remote}",
46
- "lcd #{local}",
47
- "cd #{remote}",
48
- lftp_mirror_arguments(reverse, exclude)
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 --no-perms --allow-suid --no-umask --parallel=5"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_litterla: true
2
2
 
3
3
  module Photocopier
4
- VERSION = "1.3.0.pre".freeze
4
+ VERSION = "1.3.0.pre2".freeze
5
5
  end
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.pre
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-27 00:00:00.000000000 Z
13
+ date: 2018-07-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport