capistrano-file-transfer-ext 0.0.2 → 0.0.3
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.
@@ -7,7 +7,20 @@ module Capistrano
|
|
7
7
|
class Configuration
|
8
8
|
module Actions
|
9
9
|
module FileTransferExt
|
10
|
-
|
10
|
+
# FIXME: better way to filter out hexdigests from output of md5sum (both GNU and BSD).
|
11
|
+
# currently, we regards 16+ consecutive [0-9a-f] as string of hexdigest.
|
12
|
+
# since mawk does not recognize /.{n}/ style quantifier, the regex is very scary.
|
13
|
+
DIGEST_FILTER_CMD = "awk '%s'" % %q{
|
14
|
+
{
|
15
|
+
for(n=1;n<=NF;n++){
|
16
|
+
if(match($n,
|
17
|
+
"^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]+$"
|
18
|
+
)){
|
19
|
+
print($n);break
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}.gsub(/\s+/, "").strip
|
11
24
|
|
12
25
|
def safe_put(data, path, options={})
|
13
26
|
opts = options.dup
|
@@ -62,13 +75,15 @@ module Capistrano
|
|
62
75
|
digest = nil
|
63
76
|
end
|
64
77
|
end
|
78
|
+
logger.debug("#{digest_method.upcase}(#{target}) = #{digest}")
|
65
79
|
if dry_run
|
66
80
|
logger.debug("transfering: #{[direction, from, to] * ', '}")
|
67
81
|
else
|
68
82
|
execute_on_servers(options) do |servers|
|
69
83
|
targets = servers.map { |server| sessions[server] }.reject { |session|
|
70
84
|
remote_digest = session.exec!("test -f #{remote_target.dump} && #{digest_cmd} #{remote_target.dump} | #{DIGEST_FILTER_CMD}")
|
71
|
-
|
85
|
+
logger.debug("#{session.xserver.host}: #{digest_method.upcase}(#{remote_target}) = #{remote_digest}")
|
86
|
+
result = !( digest.nil? or remote_digest.nil? ) && digest.strip == remote_digest.strip
|
72
87
|
logger.info("#{session.xserver.host}: skip transfering since no changes: #{[direction, from, to] * ', '}") if result
|
73
88
|
result
|
74
89
|
}
|
@@ -113,9 +128,21 @@ module Capistrano
|
|
113
128
|
digest_cmd = options.fetch(:digest_cmd, "#{digest_method.downcase}sum")
|
114
129
|
execute = []
|
115
130
|
execute << %{( test -d #{File.dirname(to).dump} || #{try_sudo} mkdir -p #{File.dirname(to).dump} )}
|
116
|
-
|
117
|
-
execute << %{
|
118
|
-
execute << %{
|
131
|
+
# calculate hexdigest of `from'
|
132
|
+
execute << %{from=$(#{digest_cmd} #{from.dump} 2>/dev/null | #{DIGEST_FILTER_CMD} || true)}
|
133
|
+
execute << %{echo %s} % ["#{digest_method.upcase}(#{from}) = ${from}".dump]
|
134
|
+
# calculate hexdigest of `to'
|
135
|
+
execute << %{to=$(#{digest_cmd} #{to.dump} 2>/dev/null | #{DIGEST_FILTER_CMD} || true)}
|
136
|
+
execute << %{echo %s} % ["#{digest_method.upcase}(#{to}) = ${to}".dump]
|
137
|
+
# check the hexdigests
|
138
|
+
execute << (<<-EOS).gsub(/\s+/, " ").strip
|
139
|
+
if [ -n "${from}" -a "${to}" ] && [ "${from}" = "${to}" ]; then
|
140
|
+
echo "skip placing since no changes.";
|
141
|
+
else
|
142
|
+
#{try_sudo} mv -f #{from.dump} #{to.dump};
|
143
|
+
fi
|
144
|
+
EOS
|
145
|
+
|
119
146
|
if mode
|
120
147
|
mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s
|
121
148
|
execute << "#{try_sudo} chmod #{mode} #{to.dump}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-file-transfer-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-02-
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -67,4 +67,3 @@ signing_key:
|
|
67
67
|
specification_version: 3
|
68
68
|
summary: A sort of utilities which helps you transferring files with Capistrano.
|
69
69
|
test_files: []
|
70
|
-
has_rdoc:
|