fix(nbstore): check before save empty update (#10304)

This commit is contained in:
EYHN
2025-02-20 04:24:49 +00:00
parent 1d339c682b
commit 5042d9f644
2 changed files with 23 additions and 9 deletions

View File

@@ -437,6 +437,7 @@ export class DocSyncPeer {
data.length > 0 ? await this.mergeUpdates(data) : new Uint8Array(); data.length > 0 ? await this.mergeUpdates(data) : new Uint8Array();
throwIfAborted(signal); throwIfAborted(signal);
if (!isEmptyUpdate(update)) {
await this.local.pushDocUpdate( await this.local.pushDocUpdate(
{ {
docId, docId,
@@ -444,6 +445,7 @@ export class DocSyncPeer {
}, },
this.uniqueId this.uniqueId
); );
}
throwIfAborted(signal); throwIfAborted(signal);
await this.syncMetadata.setPeerPulledRemoteClock(this.peerId, { await this.syncMetadata.setPeerPulledRemoteClock(this.peerId, {

View File

@@ -1,5 +1,5 @@
import { IndexedDBDocStorage } from '@affine/nbstore/idb'; import { IndexedDBDocStorage, IndexedDBSyncStorage } from '@affine/nbstore/idb';
import { SqliteDocStorage } from '@affine/nbstore/sqlite'; import { SqliteDocStorage, SqliteSyncStorage } from '@affine/nbstore/sqlite';
import type { StoreClient } from '@affine/nbstore/worker/client'; import type { StoreClient } from '@affine/nbstore/worker/client';
import { Entity } from '@toeverything/infra'; import { Entity } from '@toeverything/infra';
@@ -16,6 +16,10 @@ export class UserDBEngine extends Entity<{
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
? SqliteDocStorage ? SqliteDocStorage
: IndexedDBDocStorage; : IndexedDBDocStorage;
SyncStorageType =
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS
? SqliteSyncStorage
: IndexedDBSyncStorage;
canGracefulStop() { canGracefulStop() {
// TODO(@eyhn): Implement this // TODO(@eyhn): Implement this
@@ -40,6 +44,14 @@ export class UserDBEngine extends Entity<{
type: 'userspace', type: 'userspace',
}, },
}, },
sync: {
name: this.SyncStorageType.identifier,
opts: {
id: `${serverService.server.id}:` + this.userId,
type: 'userspace',
flavour: serverService.server.id,
},
},
}, },
remotes: { remotes: {
cloud: { cloud: {