lib/dbox/syncer.rb in dbox-0.6.10 vs lib/dbox/syncer.rb in dbox-0.6.11

- old
+ new

@@ -207,11 +207,11 @@ if res.kind_of?(Array) && res[0] == :conflict changelist[:conflicts] ||= [] changelist[:conflicts] << res[1] end rescue Exception => e - log.error "Error while downloading #{c[:path]}: #{e.inspect}" + log.error "Error while downloading #{c[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" parent_ids_of_failed_entries << c[:parent_id] changelist[:failed] << { :operation => :create, :path => c[:path], :error => e } end end end @@ -230,20 +230,23 @@ if res.kind_of?(Array) && res[0] == :conflict changelist[:conflicts] ||= [] changelist[:conflicts] << res[1] end rescue Exception => e - log.error "Error while downloading #{c[:path]}: #{e.inspect}" + log.error "Error while downloading #{c[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" parent_ids_of_failed_entries << c[:parent_id] changelist[:failed] << { :operation => :create, :path => c[:path], :error => e } end end end when :delete c[:is_dir] ? delete_dir(c) : delete_file(c) database.delete_entry_by_path(c[:path]) changelist[:deleted] << c[:path] + when :failed + parent_ids_of_failed_entries << c[:parent_id] + changelist[:failed] << { :operation => c[:operation], :path => c[:path], :error => c[:error] } else raise(RuntimeError, "Unknown operation type: #{op}") end end @@ -322,12 +325,12 @@ Thread.new do begin clone_api_into_current_thread() Thread.current[:out] = calculate_changes(dir, operation) rescue Exception => e - log.error "Error while caclulating changes #{dir.inspect}: #{operation}" - log.error e.inspect + log.error "Error while caclulating changes for #{operation} on #{dir[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" + Thread.current[:out] = [[:failed, dir.merge({ :operation => operation, :error => e })]] end end end threads.each {|t| t.join; out += t[:out] } @@ -471,11 +474,11 @@ log.warn "#{c[:path]} had a conflict and was renamed to #{res[:path]} on the server" changelist[:conflicts] ||= [] changelist[:conflicts] << { :original => c[:path], :renamed => res[:path] } end rescue Exception => e - log.error "Error while uploading #{c[:path]}: #{e.inspect}" + log.error "Error while uploading #{c[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" changelist[:failed] << { :operation => :create, :path => c[:path], :error => e } end end end when :update @@ -500,11 +503,11 @@ log.warn "#{c[:path]} had a conflict and was renamed to #{res[:path]} on the server" changelist[:conflicts] ||= [] changelist[:conflicts] << { :original => c[:path], :renamed => res[:path] } end rescue Exception => e - log.error "Error while uploading #{c[:path]}: #{e.inspect}" + log.error "Error while uploading #{c[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" changelist[:failed] << { :operation => :update, :path => c[:path], :error => e } end end end when :delete @@ -521,13 +524,15 @@ # safe to delete even if remote is already gone end database.delete_entry_by_path(c[:path]) changelist[:deleted] << c[:path] rescue Exception => e - log.error "Error while deleting #{c[:path]}: #{e.inspect}" + log.error "Error while deleting #{c[:path]}: #{e.inspect}\n#{e.backtrace.join("\n")}" changelist[:failed] << { :operation => :delete, :path => c[:path], :error => e } end end + when :failed + changelist[:failed] << { :operation => c[:operation], :path => c[:path], :error => c[:error] } else raise(RuntimeError, "Unknown operation type: #{op}") end end