mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 04:42:56 +08:00
fix(electron): only update db after data changed (#5226)
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { equal } from 'node:assert';
|
|
||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
|
|
||||||
import { SqliteConnection } from '@affine/native';
|
import { SqliteConnection } from '@affine/native';
|
||||||
@@ -78,19 +77,23 @@ export const migrateToLatest = async (
|
|||||||
};
|
};
|
||||||
await downloadBinary(rootDoc, true);
|
await downloadBinary(rootDoc, true);
|
||||||
const result = await forceUpgradePages(rootDoc, schema);
|
const result = await forceUpgradePages(rootDoc, schema);
|
||||||
equal(result, true, 'migrateWorkspace should return boolean value');
|
if (result) {
|
||||||
const uploadBinary = async (doc: YDoc, isRoot: boolean) => {
|
const uploadBinary = async (doc: YDoc, isRoot: boolean) => {
|
||||||
await connection.replaceUpdates(doc.guid, [
|
await connection.replaceUpdates(doc.guid, [
|
||||||
{ docId: isRoot ? undefined : doc.guid, data: encodeStateAsUpdate(doc) },
|
{
|
||||||
]);
|
docId: isRoot ? undefined : doc.guid,
|
||||||
// connection..applyUpdate(encodeStateAsUpdate(doc), 'self', doc.guid)
|
data: encodeStateAsUpdate(doc),
|
||||||
await Promise.all(
|
},
|
||||||
[...doc.subdocs].map(subdoc => {
|
]);
|
||||||
return uploadBinary(subdoc, false);
|
// connection..applyUpdate(encodeStateAsUpdate(doc), 'self', doc.guid)
|
||||||
})
|
await Promise.all(
|
||||||
);
|
[...doc.subdocs].map(subdoc => {
|
||||||
};
|
return uploadBinary(subdoc, false);
|
||||||
await uploadBinary(rootDoc, true);
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
await uploadBinary(rootDoc, true);
|
||||||
|
}
|
||||||
await connection.close();
|
await connection.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user