-
Notifications
You must be signed in to change notification settings - Fork 1
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
implement media server in MapeoManager #365
Changes from 16 commits
39bc4cb
077492c
7f5284c
421b010
df3544b
b2f0aec
81d909a
b44c2fa
2800c72
8bef7ef
84c9f74
cc61a9b
58ed4f0
c2503cc
95b5d62
943dc63
b154eea
4c38fff
e50272d
64861a3
9ae53a6
5b0d7e8
a90efe4
3d4bbd4
3dfbf27
2e13b42
3282473
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import { CoreManager, NAMESPACES } from './core-manager/index.js' | |
import { DataStore } from './datastore/index.js' | ||
import { DataType, kCreateWithDocId } from './datatype/index.js' | ||
import { BlobStore } from './blob-store/index.js' | ||
import { createBlobServer } from './blob-server/index.js' | ||
import { BlobApi } from './blob-api.js' | ||
import { IndexWriter } from './index-writer/index.js' | ||
import { projectSettingsTable } from './schema/client.js' | ||
|
@@ -30,7 +29,12 @@ import { | |
mapAndValidateCoreOwnership, | ||
} from './core-ownership.js' | ||
import { Capabilities } from './capabilities.js' | ||
import { getDeviceId, projectKeyToId, valueOf } from './utils.js' | ||
import { | ||
getDeviceId, | ||
projectKeyToId, | ||
projectKeyToPublicId, | ||
valueOf, | ||
} from './utils.js' | ||
import { MemberApi } from './member-api.js' | ||
import { SyncController } from './sync/sync-controller.js' | ||
|
||
|
@@ -42,6 +46,7 @@ export const kCoreOwnership = Symbol('coreOwnership') | |
export const kCapabilities = Symbol('capabilities') | ||
export const kSetOwnDeviceInfo = Symbol('kSetOwnDeviceInfo') | ||
export const kReplicate = Symbol('replicate') | ||
export const kBlobStore = Symbol('blobStore') | ||
|
||
export class MapeoProject { | ||
#projectId | ||
|
@@ -50,12 +55,12 @@ export class MapeoProject { | |
#dataStores | ||
#dataTypes | ||
#blobStore | ||
#blobServer | ||
#coreOwnership | ||
#capabilities | ||
#ownershipWriteDone | ||
#memberApi | ||
#syncController | ||
#projectPublicId | ||
|
||
/** | ||
* @param {Object} opts | ||
|
@@ -68,6 +73,7 @@ export class MapeoProject { | |
* @param {IndexWriter} opts.sharedIndexWriter | ||
* @param {import('./types.js').CoreStorage} opts.coreStorage Folder to store all hypercore data | ||
* @param {import('./local-peers.js').LocalPeers} opts.rpc | ||
* @param {(mediaType: 'blobs' | 'icons') => Promise<string>} opts.getMediaBaseUrl | ||
* | ||
*/ | ||
constructor({ | ||
|
@@ -80,9 +86,11 @@ export class MapeoProject { | |
projectSecretKey, | ||
encryptionKeys, | ||
rpc, | ||
getMediaBaseUrl, | ||
}) { | ||
this.#deviceId = getDeviceId(keyManager) | ||
this.#projectId = projectKeyToId(projectKey) | ||
this.#projectPublicId = projectKeyToPublicId(projectKey) | ||
|
||
///////// 1. Setup database | ||
const sqlite = new Database(dbPath) | ||
|
@@ -205,18 +213,10 @@ export class MapeoProject { | |
coreManager: this.#coreManager, | ||
}) | ||
|
||
this.#blobServer = createBlobServer({ | ||
logger: true, | ||
blobStore: this.#blobStore, | ||
prefix: '/blobs/', | ||
projectId: this.#projectId, | ||
}) | ||
|
||
// @ts-ignore TODO: pass in blobServer | ||
this.$blobs = new BlobApi({ | ||
projectId: this.#projectId, | ||
projectId: this.#projectPublicId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename this in the PR to avoid confusion later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed via 3dfbf27 |
||
blobStore: this.#blobStore, | ||
blobServer: this.#blobServer, | ||
getMediaBaseUrl: async () => getMediaBaseUrl('blobs'), | ||
}) | ||
|
||
this.#coreOwnership = new CoreOwnership({ | ||
|
@@ -286,6 +286,10 @@ export class MapeoProject { | |
return this.#capabilities | ||
} | ||
|
||
get [kBlobStore]() { | ||
return this.#blobStore | ||
} | ||
|
||
get deviceId() { | ||
return this.#deviceId | ||
} | ||
|
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 fixes the e2e media-server test, but it breaks the blob-api test because the hash is incorrect.