-
Notifications
You must be signed in to change notification settings - Fork 0
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
Local files based sync #249
Conversation
- basically a temporary bit of code so I can conver the Chronicles database to an index over files, where files are the source of truth; this is how older versions of chronicles worked.
a817215
to
bad6e03
Compare
|
||
export interface GetDocumentResponse { | ||
id: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
title?: string; | ||
content: string; | ||
journalId: string; | ||
journal: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-worked the journal references from id to name, to support reconciling synced journal names with what's in the cache. Probably this was a mistake, but I tied up the change too tightly to all the other work; may re-visit this in the near future.
updatedAt: new Date().toISOString(), | ||
}); | ||
|
||
// todo: dumb; revert to having documents reference id instead of name | ||
this.db | ||
.prepare("update documents set journal = :newName where journal = :name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of where changing the reference to be by name results in extra work; obviously dumb design here. But works for now....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This importer is a legacy of the prior file-based format, which IIRC was something like:
/my_journal
2024/
/04
/01
# etc
Because I did not use front-matter, and because the ctime
/ mtime
could be changed by bulk file moves / zip / cloud sync, I relied on the filename for the date of the note. I think it makes sense to leave this until I'm satisfied with the final format of Chronicles data, and especially until I introduce markdown importers.
This large set of changes converts the database from source of truth to a cache over the file system, where the source of truth is a directory of markdown files + attachments. This returns Chronicles persistence to an earlier design and should improve its ability to work via file-system cloud-sync, like iCloud, out of the box. It introduces a "Sync" operation and numerous supporting changes, along with a few semi-related improvements or fixes uncovered while hacking away. There remain a few related changes to ensure the sync experience is smooth; as is the user would need to manually sync when switching devices.
bad6e03
to
233ef32
Compare
Re-works the database back to a cache over files - the app now layers over a directory of markdown files where the files are the source of truth. This is how the app was originally envisioned / previously implemented (see #61).
This requires the directory to adhere to the following structure:
Screenshot of my notes directory:
Note title, tags, and create / updated timestamps are stored in front matter:
The filename serves as the unique identifier for the document; id format will be revisted in #248 , support for additional front matter (at least, preserving its existence) will be reviewed in #127
I have a lot of mixed feelings about the work in this PR. It makes everything about the application more complicated. It hopefully sets up better for default sync (via iCloud, whatever), but there remains a few more tasks to make it a bit more robust. It will likely have some issues, but should be safer than syncing the database (What I was doing previously -- I wasn't using the app daily until recently). At this point going to roll with it a while and make some more incremental changes, as documented in #247