-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Desktop: File system mirroring #10448
base: dev
Are you sure you want to change the base?
Desktop: File system mirroring #10448
Conversation
…items are created
I'm linking to the relevant discussion on Lemmy: https://sopuli.xyz/post/12850169 For now, this pull request focuses on desktop and CLI. On Android (when it's implemented :) ), selecting a directory to sync with will probably be similar to the existing file system sync logic. As such, if the current file system sync works with Cryptomator, then this should, too. |
Parentheses were causing issues with markdown link parsing. They may need to be escaped in a future commit. For now, duplicate items use a `--1`, `--2`, ..., `--n` suffix instead of `(1)`, `(2)`, ... .
…update local metadata
Summary
This pull request adds support for syncing a folder and its subfolders with the file system. This has a few differences from existing file system sync:
Development: New files/classes
New classes
At present, file system mirroring involves several different objects:
FolderMirroringService
FolderMirror
LinkTracker
ItemTree
FolderMirror
A
FolderMirror
is responsible for syncing one notebook and all of its subnotebooks with a filesystem directory. It is designed to do two things:Internally, it uses two
ItemTree
s to keep track of the state. One represents the database state and the other the file system state. This is done because paths can be different (particularly when starting a newfullSync
) in the file system and database.ItemTree
ItemTree
s map from paths to folder and note entities and from IDs to paths. Internally, all paths are POSIX paths relative to the root output folder. For example,out/a.md
.An
ItemTree
has various methods for manipulating the tree. For example,move
anddeleteItemAtPath
. Each such method takes alisteners
parameter that the caller uses to determine what effect (if any) the method should have.For example, different
listeners
can make a call update the database/file system, or just the tree:LinkTracker
Each
FolderMirror
has aLinkTracker
.LinkTracker
s maintain a graph of links between notes. After a full sync, the local and remote graphs should be identical. As such, a link tracker is created only for the remote tree.Note: File system notes use paths for links (e.g.
[link](../target.md)
) instead of IDs (e.g.[link](:/0123456789abcdef0123456789abcdef)
).When a note is renamed, the
LinkTracker
determines what other notes need to be updated with the new path. It also handles conversion between ID links and path links.FolderMirroringService
The
FolderMirroringService
is responsible for creating and managingFolderMirror
objects. EachFolderMirror
is responsible for mirroring a notebook and its subnotebooks to a single directory in the file system.The service ensures that multiple
FolderMirror
s aren't created for the same directory and, if aFolderMirror
for a(folder, destination)
already exists, re-uses that mirror for future calls.The
FolderMirroringService
is also responsible for forwarding database events to individualFolderMirror
objects.Screen recording
file-mirror-demo.mp4
To-do
.metadata.yml
files for resources and folders, try to guess the ID of folders and resources based on the notes that they contain or that reference them.id
property. If these notes already exist within Joplin, then theparent_id
of the majority of these notes ID of their parent folder in Joplin can provide the ID of the remote folder.AsyncActionQueue