lib/dbox/syncer.rb in dbox-0.6.2 vs lib/dbox/syncer.rb in dbox-0.6.3
- old
+ new
@@ -146,10 +146,24 @@
end
def remove_tmpfiles
Dir["#{local_path}/.*.part"].each {|f| FileUtils.rm(f) }
end
+
+ def sort_changelist(changelist)
+ changelist.keys.each do |k|
+ case k
+ when :conflicts
+ changelist[k].sort! {|c1, c2| c1[:original] <=> c2[:original] }
+ when :failed
+ changelist[k].sort! {|c1, c2| c1[:path] <=> c2[:path] }
+ else
+ changelist[k].sort!
+ end
+ end
+ changelist
+ end
end
class Pull < Operation
def initialize(database, api)
super(database, api)
@@ -241,12 +255,11 @@
parent_ids_of_failed_entries.uniq.each do |id|
database.update_entry_by_id(id, :remote_hash => nil)
end
# sort & return output
- changelist.keys.each {|k| k == :conflicts ? changelist[k].sort! {|c1, c2| c1[:original] <=> c2[:original] } : changelist[k].sort! }
- changelist
+ sort_changelist(changelist)
end
def calculate_changes(dir, operation = :update)
raise(ArgumentError, "Not a directory: #{dir.inspect}") unless dir[:is_dir]
@@ -516,11 +529,10 @@
# wait for operations to finish
ptasks.finish
# sort & return output
- changelist.keys.each {|k| changelist[k].sort! }
- changelist
+ sort_changelist(changelist)
end
def calculate_changes(dir)
raise(ArgumentError, "Not a directory: #{dir.inspect}") unless dir[:is_dir]