bin/s3cmd in cprobert-s3sync-1.3.7 vs bin/s3cmd in cprobert-s3sync-1.3.9
- old
+ new
@@ -112,19 +112,21 @@
marker = nil
while more do
res = s3cmdList(bucket, path, nil, nil, marker)
res.entries.each do |item|
# the s3 commands (with my modified UTF-8 conversion) expect native char encoding input
- key = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ #key = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ key = item.key.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "")
$stderr.puts "delete #{bucket}:#{key} #{headers.inspect if headers}" if $S3syncOptions['--verbose']
S3try(:delete, bucket, key) unless $S3syncOptions['--dryrun']
end
more = res.properties.is_truncated
marker = (res.properties.next_marker)? res.properties.next_marker : ((res.entries.length > 0) ? res.entries.last.key : nil)
# get this into local charset; when we pass it to s3 that is what's expected
- marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ #marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ marker = marker.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "") if marker
end
when "list"
s3cmdUsage("Need a bucket") if bucket == ''
max, delim = ARGV[2..3]
@@ -136,23 +138,26 @@
marker = nil
while more do
res = s3cmdList(bucket, path, max, delim, marker, headers)
if delim
res.common_prefix_entries.each do |item|
- puts "dir: " + Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.prefix).join
+ puts "dir: " + item.prefix.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "")
+ #puts "dir: " + Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.prefix).join
end
puts "--------------------"
end
res.entries.each do |item|
- puts Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ puts item.key.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "")
+ #puts Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
end
if res.properties.is_truncated
printf "More? Y/n: "
more = (STDIN.gets.match('^[Yy]?$'))
marker = (res.properties.next_marker)? res.properties.next_marker : ((res.entries.length > 0) ? res.entries.last.key : nil)
# get this into local charset; when we pass it to s3 that is what's expected
- marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ #marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ marker = marker.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "") if marker
else
more = false
end
end # more
@@ -262,11 +267,12 @@
marker = nil
while more do
res = s3cmdList(bucket, path, nil, nil, marker)
res.entries.each do |item|
# the s3 commands (with my modified UTF-8 conversion) expect native char encoding input
- path = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ #path = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ path = item.key.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "")
file = path.gsub(src_path, dest_key)
headers = hashPairs(ARGV[3...ARGV.length])
if headers.length > 0
@@ -282,11 +288,12 @@
end
more = res.properties.is_truncated
marker = (res.properties.next_marker)? res.properties.next_marker : ((res.entries.length > 0) ? res.entries.last.key : nil)
# get this into local charset; when we pass it to s3 that is what's expected
- marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ #marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ marker = marker.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "") if marker
end
when "headers"
s3cmdUsage("Need a bucket") if bucket == ''
s3cmdUsage("Need a path") if path == ''
@@ -298,11 +305,12 @@
marker = nil
while more do
res = s3cmdList(bucket, path, nil, nil, marker)
res.entries.each do |item|
# the s3 commands (with my modified UTF-8 conversion) expect native char encoding input
- key = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ #key = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", item.key).join
+ key = item.key.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "")
tmpHeaders = headers.merge({
"x-amz-copy-source" => "/#{bucket}/#{URI.escape(key)}",
"x-amz-metadata-directive" => "REPLACE"
})
@@ -320,10 +328,11 @@
end
more = res.properties.is_truncated
marker = (res.properties.next_marker)? res.properties.next_marker : ((res.entries.length > 0) ? res.entries.last.key : nil)
# get this into local charset; when we pass it to s3 that is what's expected
- marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ #marker = Iconv.iconv($S3SYNC_NATIVE_CHARSET, "UTF-8", marker).join if marker
+ marker = marker.encode($S3SYNC_NATIVE_CHARSET, :invalid => :replace, :undef => :replace, :replace => "") if marker
end
else
s3cmdUsage