mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 13:17:10 +08:00
feat(nbstore): add blob sync frontend (#9084)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { BlobRecord, BlobStorage } from '../storage';
|
||||
import type { BlobSyncEngine } from '../sync/blob';
|
||||
|
||||
export class BlobFrontend {
|
||||
constructor(
|
||||
readonly storage: BlobStorage,
|
||||
readonly sync?: BlobSyncEngine
|
||||
) {}
|
||||
|
||||
get(blobId: string) {
|
||||
return this.sync
|
||||
? this.sync.downloadBlob(blobId)
|
||||
: this.storage.get(blobId);
|
||||
}
|
||||
|
||||
set(blob: BlobRecord) {
|
||||
return this.sync ? this.sync.uploadBlob(blob) : this.storage.set(blob);
|
||||
}
|
||||
|
||||
addPriority(id: string, priority: number) {
|
||||
return this.sync?.addPriority(id, priority);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user