mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +08:00
feat(nbstore): improve nbstore (#9512)
This commit is contained in:
@@ -3,21 +3,33 @@ import type { BlobSync } from '../sync/blob';
|
||||
|
||||
export class BlobFrontend {
|
||||
constructor(
|
||||
readonly storage: BlobStorage,
|
||||
readonly sync?: BlobSync
|
||||
public readonly storage: BlobStorage,
|
||||
private readonly sync: BlobSync
|
||||
) {}
|
||||
|
||||
get(blobId: string) {
|
||||
return this.sync
|
||||
? this.sync.downloadBlob(blobId)
|
||||
: this.storage.get(blobId);
|
||||
return this.sync.downloadBlob(blobId);
|
||||
}
|
||||
|
||||
set(blob: BlobRecord) {
|
||||
return this.sync ? this.sync.uploadBlob(blob) : this.storage.set(blob);
|
||||
return this.sync.uploadBlob(blob);
|
||||
}
|
||||
|
||||
fullSync() {
|
||||
return this.sync.fullSync();
|
||||
}
|
||||
|
||||
addPriority(_id: string, _priority: number) {
|
||||
// not support yet
|
||||
}
|
||||
|
||||
readonly state$ = this.sync.state$;
|
||||
|
||||
setMaxBlobSize(max: number) {
|
||||
this.sync.setMaxBlobSize(max);
|
||||
}
|
||||
|
||||
onReachedMaxBlobSize(cb: (byteSize: number) => void): () => void {
|
||||
return this.sync.onReachedMaxBlobSize(cb);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user