mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
feat(nbstore): add blob sync storage (#10752)
This commit is contained in:
@@ -106,6 +106,7 @@ export class CMDKQuickSearchService extends Service {
|
||||
primaryMode: 'page',
|
||||
docProps,
|
||||
});
|
||||
|
||||
this.workbenchService.workbench.openDoc(newDoc.id);
|
||||
} else if (result.id === 'creation:create-edgeless') {
|
||||
const newDoc = this.docsService.createDoc({
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
import { CloudBlobStorage, StaticCloudDocStorage } from '@affine/nbstore/cloud';
|
||||
import {
|
||||
IndexedDBBlobStorage,
|
||||
IndexedDBBlobSyncStorage,
|
||||
IndexedDBDocStorage,
|
||||
IndexedDBDocSyncStorage,
|
||||
} from '@affine/nbstore/idb';
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
} from '@affine/nbstore/idb/v1';
|
||||
import {
|
||||
SqliteBlobStorage,
|
||||
SqliteBlobSyncStorage,
|
||||
SqliteDocStorage,
|
||||
SqliteDocSyncStorage,
|
||||
} from '@affine/nbstore/sqlite';
|
||||
@@ -115,6 +117,10 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
|
||||
? SqliteDocSyncStorage
|
||||
: IndexedDBDocSyncStorage;
|
||||
BlobSyncStorageType =
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
|
||||
? SqliteBlobSyncStorage
|
||||
: IndexedDBBlobSyncStorage;
|
||||
|
||||
async deleteWorkspace(id: string): Promise<void> {
|
||||
await this.graphqlService.gql({
|
||||
@@ -439,6 +445,14 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
id: workspaceId,
|
||||
},
|
||||
},
|
||||
blobSync: {
|
||||
name: this.BlobSyncStorageType.identifier,
|
||||
opts: {
|
||||
flavour: this.flavour,
|
||||
type: 'workspace',
|
||||
id: workspaceId,
|
||||
},
|
||||
},
|
||||
awareness: {
|
||||
name: 'BroadcastChannelAwarenessStorage',
|
||||
opts: {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@affine/nbstore';
|
||||
import {
|
||||
IndexedDBBlobStorage,
|
||||
IndexedDBBlobSyncStorage,
|
||||
IndexedDBDocStorage,
|
||||
IndexedDBDocSyncStorage,
|
||||
} from '@affine/nbstore/idb';
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
} from '@affine/nbstore/idb/v1';
|
||||
import {
|
||||
SqliteBlobStorage,
|
||||
SqliteBlobSyncStorage,
|
||||
SqliteDocStorage,
|
||||
SqliteDocSyncStorage,
|
||||
} from '@affine/nbstore/sqlite';
|
||||
@@ -101,6 +103,10 @@ class LocalWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
|
||||
? SqliteDocSyncStorage
|
||||
: IndexedDBDocSyncStorage;
|
||||
BlobSyncStorageType =
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
|
||||
? SqliteBlobSyncStorage
|
||||
: IndexedDBBlobSyncStorage;
|
||||
|
||||
async deleteWorkspace(id: string): Promise<void> {
|
||||
setLocalWorkspaceIds(ids => ids.filter(x => x !== id));
|
||||
@@ -321,6 +327,14 @@ class LocalWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
id: workspaceId,
|
||||
},
|
||||
},
|
||||
blobSync: {
|
||||
name: this.BlobSyncStorageType.identifier,
|
||||
opts: {
|
||||
flavour: this.flavour,
|
||||
type: 'workspace',
|
||||
id: workspaceId,
|
||||
},
|
||||
},
|
||||
docSync: {
|
||||
name: this.DocSyncStorageType.identifier,
|
||||
opts: {
|
||||
|
||||
@@ -63,5 +63,10 @@ export class WorkspaceEngine extends Entity<{
|
||||
this.doc.addPriority(rootDoc.guid, 100);
|
||||
this.doc.start();
|
||||
this.disposables.push(() => this.doc.stop());
|
||||
|
||||
// fully migrate blobs from v1 to v2, its won't do anything if v1 storage is not exist
|
||||
store.blobFrontend.fullDownload('v1').catch(() => {
|
||||
// should never reach here
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user