You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
Add an option to switch between in-memory and sqlite storage
Add an option for a directory in which to store the sqlite files
Generate safe filenames for the sqlite files, from the workspace address (see below)
Instantiate a StorageSqlite instead of a StorageMemory.
How to validate a workspace address and use it as a filename
A workspace address looks like +gardenclub.jaoidf23jdoq9dj. Remove the leading + and append .sqlite to make a filename. Make sure to validate the string as a proper workspace address using ValidatorES4._checkWorkspaceIsValid from the earthstar package. (Valid workspace addresses are safe as filenames.)
import{ValidatorES4,isErr,notErr}from'earthstar';letaddr='+foo.xxxxxxx';leterr=ValidatorES4._checkWorkspaceIsValid(addr);if(isErr(err)){console.error('bad workspace address: '+err.message);}else{// addr is now a valid workspace addressletfilename=addr.slice(1)+'.sqlite';// remove leading '+'// filename is now is guaranteed to be safe for use as a filename}
The text was updated successfully, but these errors were encountered:
Right now we're using the in-memory Earthstar storage, which forgets everything when the pub is restarted.
Add an option to store each workspace in its own sqlite file in a configurable directory.
Places to make changes:
obtainStorage
function is where Storage classes are instantiated for new workspacesChanges:
StorageSqlite
instead of aStorageMemory
.How to validate a workspace address and use it as a filename
A workspace address looks like
+gardenclub.jaoidf23jdoq9dj
. Remove the leading+
and append.sqlite
to make a filename. Make sure to validate the string as a proper workspace address usingValidatorES4._checkWorkspaceIsValid
from theearthstar
package. (Valid workspace addresses are safe as filenames.)The text was updated successfully, but these errors were encountered: