This adds a new function called syncReplicaAndFsDir, which synchronises an Earthstar replica with a filesystem directory.
Earthstar docs are written to the filesystem as files, and changes from the filesystem are written onto the replica.
Changes from the filesystem are also set with timestamps, so even if a file is overwritten by an external change (i.e. a friend making a change to a document), the previous content from the file will still be persisted to the replica as one of the document's versions. This gives us scope for some form of conflict resolution.
Some extra bookkeeping is done using a hidden manifest file stored at .es-fs-manifest at the root of the folder being synced.
A few caveats, as the mapping from the filesystem to Earthstar is not perfect:
The function will throw if a file larger than 4mb is present in the directory (this is the limit of the ES4 format - watch this space)
The function will throw if a change is made at a path owned by an identity other than the one provided to the function.
The function will throw if a change is made at a path considered invalid by Earthstar (e.g. starting with a @)
For the moment this function is exclusive to the Deno distribution. Theoretically it can be automatically mapped to the Node version, but there are some issues I'm trying to resolve.
This adds a new function called
syncReplicaAndFsDir
, which synchronises an Earthstar replica with a filesystem directory..es-fs-manifest
at the root of the folder being synced.A few caveats, as the mapping from the filesystem to Earthstar is not perfect:
@
)For the moment this function is exclusive to the Deno distribution. Theoretically it can be automatically mapped to the Node version, but there are some issues I'm trying to resolve.