lib/s3sync/sync.rb in s3sync-0.3.2 vs lib/s3sync/sync.rb in s3sync-0.3.3

- old
+ new

@@ -110,22 +110,22 @@ end def list_files nodes = {} Find.find(@source) do |file| - st = File.stat file + begin + st = File.stat file # Might fail + raise if not st.readable? # We're not interested in things we can't read + rescue + $stderr.puts "WARNING: Skipping unreadable file #{file}" + Find.prune + end # We don't support following symlinks for now, we don't need to follow # folders and I don't think we care about any other thing, right? next unless st.file? - # Well, we're kinda out of options right now, I'll just yell! - if not st.readable? - $stderr.puts "WARNING: Skipping unreadable file #{file}" - next - end - # We only need the relative path here file_name = file.gsub(/^#{@source}\/?/, '').squeeze('/') node = Node.new(@source.squeeze('/'), file_name, st.size) nodes[node.path] = node end @@ -225,11 +225,15 @@ # no slash on end of source means we need to append the last src dir to # dst prefix testing for empty isn't good enough here.. needs to be # "empty apart from potentially having 'bucket:'" if source =~ %r{/$} - File.join [destination, file] + if remote_prefix? destination and destination.end_with? ':' + S3Sync.safe_join [destination, file] + else + File.join [destination, file] + end else if remote_prefix? source _, name = source.split ":" File.join [destination, File.basename(name || ""), file] else @@ -264,9 +268,10 @@ source_is_s3 = remote_prefix? source # canonicalize the S3 stuff remote_prefix = source_is_s3 ? source : destination bucket, remote_prefix = remote_prefix.split ":" + remote_prefix ||= "" # Just making sure we preserve the direction if source_is_s3 [[remote_prefix, bucket], destination]