Skip to content

Commit ecc505b

Browse files
committed
Fix a bug which unmatch folder hash between boostnote.json and *.cson
1 parent a1017b9 commit ecc505b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/ever2boost/evernote_authorizer.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,31 @@ def notebook_guids
3131

3232
def notebook_list
3333
guids = self.notebook_guids
34-
self.fetch_notebook_list.map { |nl| Ever2boost::NoteList.new(title: nl.name, hash: nl.hash, guid: nl.guid) }
34+
self.fetch_notebook_list.map { |nl| Ever2boost::NoteList.new(title: nl.name, guid: nl.guid) }
3535
end
3636

3737
def number_of_note(filter)
3838
note_counts_hash = self.note_store.findNoteCounts(self.developer_token, filter, true).notebookCounts
39-
note_counts_hash.values.last || 0
39+
note_counts_hash.nil? ? 0 : note_counts_hash.values.last
4040
end
4141

4242
def fetch_notes(filter)
4343
spec = Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new(includeTitle: true, includeNotebookGuid: true)
44+
number_of_note = self.number_of_note(filter)
4445

4546
# get latest 250 notes
4647
# TODO: display message like "ignored first #{(number_of_notes - 250).to_s} notes due to EvernoteAPI access limitation" if number_of_notes > 250
47-
start_index = self.number_of_note(filter) > 250 ? self.number_of_note(filter) - 250 : 0
48-
self.note_store.findNotesMetadata(self.developer_token, filter, start_index, 15, spec)
48+
start_index = number_of_note > 250 ? number_of_note - 250 : 0
49+
self.note_store.findNotesMetadata(self.developer_token, filter, start_index, number_of_note, spec)
4950
end
5051

5152
# Download the all of notes fron Evernote and generate Boostnote storage from it
5253
# TODO: move this method to CLI
5354
def import(output_dir)
5455
FileUtils.mkdir_p(output_dir) unless FileTest.exist?(output_dir)
56+
notebook_list = self.notebook_list
5557

56-
Ever2boost::JsonGenerator.output(self.notebook_list, output_dir)
58+
Ever2boost::JsonGenerator.output(notebook_list, output_dir)
5759

5860
self.notebook_guids.each do |notebook_guid|
5961
filter = Evernote::EDAM::NoteStore::NoteFilter.new(notebookGuid: notebook_guid)
@@ -62,7 +64,7 @@ def import(output_dir)
6264
en_notes = note_guids.map {|note_guid| self.note_store.getNote(self.developer_token, note_guid, true, true, false, false)}
6365
notes = en_notes.map {|note| Note.new(title: note.title, content: note.content, notebook_guid: note.notebookGuid)}
6466
notes.each do |note|
65-
self.notebook_list.each do |list|
67+
notebook_list.each do |list|
6668
# TODO: break if note not found
6769
CsonGenerator.output(list.hash, note, output_dir) if list.guid == note.notebook_guid
6870
end

lib/ever2boost/note.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ module Ever2boost
44
class Note
55
DEFAULT_BYTES_NUMBER = 10
66
attr_accessor :title, :content, :hash, :notebook_guid, :file_name
7-
def initialize(title: nil, content: nil, hash: nil, notebook_guid: nil)
7+
def initialize(title: nil, content: nil, notebook_guid: nil)
88
@title = title
99
@content = content
10-
@hash = hash
1110
@notebook_guid = notebook_guid
1211
@file_name = SecureRandom.hex(DEFAULT_BYTES_NUMBER)
1312
end

0 commit comments

Comments
 (0)