mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 10:30:12 +08:00
23e0137ed8
This pr implements a blob engine. It exposes a single `BlobStorage` to the `blocksuite`, and in it we sync blobs between multiple storages. The implement still have few issues, but we can merge this pr first and fix them in future. * BlobEngine currently **do nothing when delete**, because synchronization logic conflicts with deletion logic. * BlobEngine sync between storages by querying the blob list at regular intervals. This will **cause many queries**, we can avoid this in the future by subscribing to remote changes.
38 lines
1008 B
TypeScript
38 lines
1008 B
TypeScript
import { BlobEngine } from './engine';
|
|
import {
|
|
createAffineCloudBlobStorage,
|
|
createIndexeddbBlobStorage,
|
|
createSQLiteBlobStorage,
|
|
createStaticBlobStorage,
|
|
} from './storage';
|
|
|
|
export * from './engine';
|
|
export * from './storage';
|
|
|
|
export function createLocalBlobStorage(workspaceId: string) {
|
|
if (environment.isDesktop) {
|
|
return createSQLiteBlobStorage(workspaceId);
|
|
} else {
|
|
return createIndexeddbBlobStorage(workspaceId);
|
|
}
|
|
}
|
|
|
|
export function createLocalBlobEngine(workspaceId: string) {
|
|
return new BlobEngine(createLocalBlobStorage(workspaceId), [
|
|
createStaticBlobStorage(),
|
|
]);
|
|
}
|
|
|
|
export function createAffineCloudBlobEngine(workspaceId: string) {
|
|
return new BlobEngine(createLocalBlobStorage(workspaceId), [
|
|
createStaticBlobStorage(),
|
|
createAffineCloudBlobStorage(workspaceId),
|
|
]);
|
|
}
|
|
|
|
export function createAffinePublicBlobEngine(workspaceId: string) {
|
|
return new BlobEngine(createAffineCloudBlobStorage(workspaceId), [
|
|
createStaticBlobStorage(),
|
|
]);
|
|
}
|