-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix: adjust storage options for MapeoManager and MapeoProject #235
Conversation
42758ad
to
68adf44
Compare
src/mapeo-project.js
Outdated
const coreManagerStorage = | ||
storagePath !== undefined | ||
typeof storage === 'string' | ||
? (name) => | ||
new RandomAccessFile( | ||
path.join(storagePath, CORE_STORAGE_FOLDER_NAME, name), | ||
path.join(dbPath, storage, CORE_STORAGE_FOLDER_NAME, name), | ||
{ pool: filePool } | ||
) | ||
: () => new RAM() | ||
: (name) => storage(path.join(CORE_STORAGE_FOLDER_NAME, name)) | ||
|
||
/** @type {ConstructorParameters<typeof DataStore>[0]['storage']} */ | ||
const indexerStorage = | ||
storagePath !== undefined | ||
typeof storage === 'string' | ||
? (name) => | ||
new RandomAccessFile( | ||
path.join(storagePath, INDEXER_STORAGE_FOLDER_NAME, name), | ||
path.join(dbPath, storage, INDEXER_STORAGE_FOLDER_NAME, name), | ||
{ pool: filePool } | ||
) | ||
: () => new RAM() | ||
: (name) => storage(path.join(INDEXER_STORAGE_FOLDER_NAME, 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.
If a path is passed, use a default random-access-file storage function
Inside MapeoProject, the storage function will still need to be wrapped to separate index storage from core storage.
Made the guess that these points applied here, but could be mistaken
src/mapeo-project.js
Outdated
* @param {import('@mapeo/crypto').KeyManager} opts.keyManager mapeo/crypto KeyManager instance | ||
* @param {Buffer} opts.projectKey 32-byte public key of the project creator core | ||
* @param {Buffer} [opts.projectSecretKey] 32-byte secret key of the project creator core | ||
* @param {Partial<Record<import('./core-manager/index.js').Namespace, Buffer>>} [opts.encryptionKeys] Encryption keys for each namespace | ||
* @param {import('drizzle-orm/better-sqlite3').BetterSQLite3Database} opts.sharedDb | ||
* @param {IndexWriter} opts.sharedIndexWriter | ||
* @param {import('./types.js').StorageParam} opts.storage Folder to store all hypercore data | ||
* @param {import('./core-manager/random-access-file-pool.js').RandomAccessFilePool} [opts.filePool] FilePool instance to use if opts.storage is a path |
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.
Create a single instance of RandomAccessFilePool in MapeoManager and use that for all storages
is this aligned with what you described here? wasn't explicitly noted to create an opt for MapeoProject but seemed to make sense given the changes required by other points
src/mapeo-manager.js
Outdated
? () => ({ | ||
dbPath: ':memory:', | ||
storage: () => new RAM(), | ||
}) |
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.
have a feeling that this shouldn't be a function that creates a new RAM instance each time a project is created. is the idea to share the ram instance across all projects too?
Not quite what I meant, sorry the issue wasn't clear. I pushed 28d4f89 to show what I meant. I think this is done now, can you review? |
Corestore already creates a `core` folder, which resulted in weird paths `cores/cores/...`, so renamed the folder to be `corestore/cores`
There are a few things that Hypercore does in its default storage for managing lock files and sparse files https://github.com/holepunchto/hypercore/blob/7c9f8b07b33e60753470728b4a9a11bcb549e158/index.js#L177
Should merge and release digidem/multi-core-indexer#17 before merging, so that we can update the snapshot and fix the storage locations |
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.
I made some changes and added a test to catch breaking changes to storage locations. There is a bug fix here for something unrelated (encoding project keys). There should be a failing test for that, in a separate PR.
your changes lgtm! thanks for making the fixes - was hoping to do this to take something off your plate but ended up with you doing most of the work anyways 😄 |
* main: (25 commits) add initial implementation of MemberApi (#232) feat: $blobs.getUrl and $blobs.create methods (#184) chore: update manager e2e tests (#237) feat: add capabilities (#231) feat: coreOwnership integration [3/3] (#230) feat: CoreOwnership class w getOwner & getCoreKey [2/3] (#229) feat: handle `coreOwnership` records in `IndexWriter` [1/3] (#214) fix: adjust storage options for MapeoManager and MapeoProject (#235) implement addProject method for MapeoManager class (#215) implement listProjects method for MapeoManager class (#208) feat: expose blobStore.writerDriveId (#219) implement wrapper client containing createProject and getProject methods (#199) add project settings functionality to MapeoProject (#187) feat: Add encode/decode for project keys [3/3] (#203) feat: update protobuf for RPC [2/3] (#202) chore: move protobuf messages into src/generated [1/3] (#201) feat: Add internal `dataType.createWithDocId()` (#192) chore: explicitly set "mode" opt for encryptionKeys column creation (#186) chore: fix linting and type checking (#183) chore: consolidate encryption key columns in projectKeys table (#181) ...
Closes #226
Tried my best to follow the checklist but there were some uncertainties, mostly around handling the
storage
opt inMapeoProject