mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
fix(workspace): avoid data loss (hot-fix) (#6114)
This commit is contained in:
@@ -13,6 +13,9 @@ export function fixWorkspaceVersion(rootDoc: YDoc) {
|
|||||||
* Blocksuite just set the value, do nothing else.
|
* Blocksuite just set the value, do nothing else.
|
||||||
*/
|
*/
|
||||||
function doFix() {
|
function doFix() {
|
||||||
|
if (meta.size === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const workspaceVersion = meta.get('workspaceVersion');
|
const workspaceVersion = meta.get('workspaceVersion');
|
||||||
if (typeof workspaceVersion !== 'number' || workspaceVersion < 2) {
|
if (typeof workspaceVersion !== 'number' || workspaceVersion < 2) {
|
||||||
transact(
|
transact(
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ export function createSQLiteStorage(workspaceId: string): SyncStorage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
if (
|
||||||
|
update.byteLength === 0 ||
|
||||||
|
(update.byteLength === 2 && update[0] === 0 && update[1] === 0)
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: update,
|
data: update,
|
||||||
state: encodeStateVectorFromUpdate(update),
|
state: encodeStateVectorFromUpdate(update),
|
||||||
|
|||||||
Reference in New Issue
Block a user