lib/frizz/sync.rb in frizz-1.7.0 vs lib/frizz/sync.rb in frizz-2.0.0

- old
+ new

@@ -9,35 +9,36 @@ changes = [] # Sync existing files remote.files.each do |remote_file| local_path = remote_file.key - local_file_md5 = local_index[local_path] + local_file = local_index[local_path] + local_file_md5 = local_file && local_file.checksum if local_file_md5.nil? puts "#{local_path}: deleted".red - remote_file.destroy + remote.delete(remote_file) changes << remote_file.key - elsif local_file_md5 == remote_file.etag + elsif local_file_md5 == remote_file.etag.gsub('"', '') puts "#{local_path}: unchanged" local_index.delete(local_path) else puts "#{local_path}: updated".green - remote.upload local.file_for(local_path), local_path + upload(local_path, local_file) local_index.delete(local_path) changes << local_path end end # Upload new files - local_index.each do |local_path, md5| + local_index.each do |local_path, local_file| puts "#{local_path}: new".green - remote.upload local.file_for(local_path), local_path + upload(local_path, local_file) changes << local_path end changes end @@ -46,10 +47,14 @@ attr_reader :local, :remote def local_index @local_index ||= local.files.each_with_object({}) do |file, obj| - obj[file.key] = file.checksum + obj[file.key] = file end end + + def upload(local_path, local_file) + remote.upload local.file_for(local_path), local_path, local_file.upload_options + end end -end \ No newline at end of file +end