file_copy 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/file_copy/copy.rb +8 -8
- data/lib/file_copy/version.rb +1 -1
- metadata +2 -2
data/lib/file_copy/copy.rb
CHANGED
@@ -13,7 +13,7 @@ module FileCopy
|
|
13
13
|
password = (password and password.length > 0) ? password : nil
|
14
14
|
port = 22 # 22 is a standart SSH port
|
15
15
|
raise "Undefined server" unless server
|
16
|
-
Log.
|
16
|
+
Log.debug1 "Trying to connect(ssh): #{username}, #{password}, #{server}, #{port}."
|
17
17
|
if (username and password)
|
18
18
|
Net::SSH.start(server, username,
|
19
19
|
:password => password,
|
@@ -36,11 +36,11 @@ module FileCopy
|
|
36
36
|
uploads = files_map.map { |from,to|
|
37
37
|
remote_dir = File.dirname(to)
|
38
38
|
sftp_mkdir_recursive(sftp, File.dirname(to))
|
39
|
-
Log.
|
39
|
+
Log.debug1 "Copying #{from} to #{to}"
|
40
40
|
sftp.upload(from, to)
|
41
41
|
}
|
42
42
|
uploads.each { |u| u.wait }
|
43
|
-
Log.
|
43
|
+
Log.debug1 "Done."
|
44
44
|
end # ssh.sftp.connect
|
45
45
|
end # def initialize
|
46
46
|
module_function :sftp_copy
|
@@ -48,17 +48,17 @@ module FileCopy
|
|
48
48
|
def sftp_mkdir_recursive(sftp, path)
|
49
49
|
dir_stat = nil
|
50
50
|
begin
|
51
|
-
Log.
|
51
|
+
Log.debug1 "Stat remote dir: #{path}."
|
52
52
|
dir_stat = sftp.stat!(path).directory?
|
53
|
-
Log.
|
53
|
+
Log.debug1 "Stat result #{dir_stat}."
|
54
54
|
rescue Net::SFTP::StatusException
|
55
55
|
end
|
56
56
|
if !dir_stat
|
57
|
-
Log.
|
57
|
+
Log.debug1 "Directory does not exists: #{path}."
|
58
58
|
sftp_mkdir_recursive sftp, File.dirname(path)
|
59
|
-
Log.
|
59
|
+
Log.debug1 "Making dir #{path}."
|
60
60
|
response = sftp.mkdir!(path)
|
61
|
-
Log.
|
61
|
+
Log.debug1 "Making dir ok:#{response.ok?}."
|
62
62
|
end
|
63
63
|
end
|
64
64
|
module_function :sftp_mkdir_recursive
|
data/lib/file_copy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log
|