Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new file format #21

Open
3 tasks
dantrevino opened this issue Jul 22, 2022 · 0 comments
Open
3 tasks

Migrate to new file format #21

dantrevino opened this issue Jul 22, 2022 · 0 comments

Comments

@dantrevino
Copy link
Contributor

dantrevino commented Jul 22, 2022

While the new format is more robust, it will only help loading performance for users with many large notes. Users with many small notes gain some robustness, but will not see any loading performance increase.

Files

riotnotes.json <-- original file
migrated.json

{
status: true,
date: datetime,
log: uri,
backup: uri
} 

index.json

{
 id: xxx-yyy-zzz
 preview: note.text.slice(120),
 img: note.attachments[0],
 fave: note.fave,
 trash: note.trash,
 color: note.color
 tags: note.tags
 modified: note.modified
}

notes/xxx-yyy-zzz.json <--- continue to use the existing note json format
migration-errors.json

{ 
 id: xxx-yyy-zzz
error: error msg
}

tasks

  • implement migration & create new files
  1. backup to backups/YYYYMMDD-riotnotes.json
  2. read & parse riotnotes.json
  3. For each note:
    -- create notes/xxx-yyy-zzz.json
    -- append xxx-yyy-zzz to index.json
  • update existing actions
    addNote()
  • add notes/xxx-yyy-zzz.json
  • add to index.json

updateNote()

  • update notes/xxx-yyy-zzz.json
  • if preview text has changed, update index.json

fetchData()

  • if index.json exists follow new loading format
    -- load previews from index.json
    -- on note load/edit, load full note from notes/xxx-yyy-zzz.json

  • else do migration

  • create new actions
    getNoteById()
    // used when note is opened in the editor

  • getFile('notes/xxx-yyy-zzz.json')

  • parse note

deleteNoteById()
// used when 'delete permanently' option is used

  • delete notes/xxx-yyy-zzz.json
  • remove xxx-yyy-zzz from index.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant