Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/staging' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
joegatt committed Dec 5, 2013
2 parents 5787418 + 1735f18 commit 3b06b2a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/syncable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def merge(new_values, overwrite = false, object = self)
end unless new_values.blank?
end

end
end
4 changes: 3 additions & 1 deletion app/models/evernote_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class EvernoteNote < ActiveRecord::Base
validates_associated :note, :evernote_auth

def self.add_task(guid)
self.where(cloud_note_identifier: guid, evernote_auth_id: evernote_auth.id).first_or_create.dirtify
evernote_note = self.where(cloud_note_identifier: guid).first_or_create
evernote_note.evernote_auth_id = evernote_auth.id
evernote_note.dirtify
end

def self.sync_all
Expand Down
6 changes: 3 additions & 3 deletions app/models/evernote_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def sync_down(evernote_note)
update_note if update_necessary? && note_is_not_conflicted?

rescue Evernote::EDAM::Error::EDAMUserException => error
max_out_attempts
evernote_note.max_out_attempts
SYNC_LOG.error I18n.t('notes.sync.rejected.not_in_notebook', logger_details)
rescue Evernote::EDAM::Error::EDAMNotFoundException => error
max_out_attempts
evernote_note.max_out_attempts
SYNC_LOG.error "Evernote: Not Found Exception: #{ error.identifier }: #{ error.key }."
rescue Evernote::EDAM::Error::EDAMSystemException => error
SYNC_LOG.error "Evernote: User Exception: #{ error.identifier }: #{ error.key }."
Expand Down Expand Up @@ -145,7 +145,7 @@ def populate
'source_application' => cloud_note_data.attributes.sourceApplication,
'source_url' => cloud_note_data.attributes.sourceURL,
'tag_list' => cloud_note_tags.grep(/^[^_]/),
'title' => cloud_note_data.title,
'title' => cloud_note_data.title
}
end

Expand Down
32 changes: 17 additions & 15 deletions app/models/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def sync_binary
unless File.file?(raw_location)
increment_attempts
Constant.stream_binaries ? stream_binary : download_binary
# We check that the resource has been downloaded correctly, if so we unflag the resource.
# Check that the resource has been downloaded correctly. If so, unflag it.
undirtify if Digest::MD5.file(raw_location).digest == data_hash
end
end
Expand Down Expand Up @@ -102,26 +102,28 @@ def make_local_file_name

# REVIEW: Put this in EvernoteNote? and mimic Books?
def update_with_evernote_data(cloud_resource, caption, description, credit)
binary_not_downloaded = (cloud_resource.data.bodyHash != data_hash)
update_attributes!(
mime: cloud_resource.mime,
width: cloud_resource.width,
height: cloud_resource.height,
caption: caption,
description: description,
credit: credit,
source_url: cloud_resource.attributes.sourceURL,
external_updated_at: cloud_resource.attributes.timestamp ? Time.at(cloud_resource.attributes.timestamp / 1000).to_datetime : nil,
latitude: cloud_resource.attributes.latitude,
longitude: cloud_resource.attributes.longitude,
altitude: cloud_resource.attributes.altitude,
attachment: cloud_resource.attributes.attachment,
attempts: 0,
camera_make: cloud_resource.attributes.cameraMake,
camera_model: cloud_resource.attributes.cameraModel,
caption: caption,
credit: credit,
data_hash: cloud_resource.data.bodyHash,
description: description,
dirty: binary_not_downloaded,
external_updated_at: cloud_resource.attributes.timestamp ? Time.at(cloud_resource.attributes.timestamp / 1000).to_datetime : nil,
file_name: cloud_resource.attributes.fileName,
attachment: cloud_resource.attributes.attachment,
height: cloud_resource.height,
latitude: cloud_resource.attributes.latitude,
local_file_name: cloud_resource.guid,
data_hash: cloud_resource.data.bodyHash,
dirty: (cloud_resource.data.bodyHash != data_hash),
attempts: 0
longitude: cloud_resource.attributes.longitude,
mime: cloud_resource.mime,
source_url: cloud_resource.attributes.sourceURL,
try_again_at: binary_not_downloaded ? Time.now : 100.years.from_now,
width: cloud_resource.width
)
end

Expand Down

0 comments on commit 3b06b2a

Please sign in to comment.