fix(workspace): dont upgrade subdoc on cloud (#5382)

This commit is contained in:
EYHN
2023-12-22 15:48:54 +08:00
committed by GitHub
parent 46f824c4e9
commit aa74b0617c
2 changed files with 9 additions and 4 deletions

View File

@@ -11,7 +11,8 @@ export enum MigrationPoint {
} }
export function checkWorkspaceCompatibility( export function checkWorkspaceCompatibility(
workspace: Workspace workspace: Workspace,
isCloud: boolean
): MigrationPoint | null { ): MigrationPoint | null {
// check if there is any key starts with 'space:' on root doc // check if there is any key starts with 'space:' on root doc
const spaceMetaObj = workspace.doc.share.get('space:meta') as const spaceMetaObj = workspace.doc.share.get('space:meta') as
@@ -20,7 +21,9 @@ export function checkWorkspaceCompatibility(
const docKeys = Array.from(workspace.doc.share.keys()); const docKeys = Array.from(workspace.doc.share.keys());
const haveSpaceMeta = !!spaceMetaObj && spaceMetaObj.size > 0; const haveSpaceMeta = !!spaceMetaObj && spaceMetaObj.size > 0;
const haveLegacySpace = docKeys.some(key => key.startsWith('space:')); const haveLegacySpace = docKeys.some(key => key.startsWith('space:'));
if (haveSpaceMeta || haveLegacySpace) {
// DON'T UPGRADE SUBDOC ON CLOUD
if (!isCloud && (haveSpaceMeta || haveLegacySpace)) {
return MigrationPoint.SubDoc; return MigrationPoint.SubDoc;
} }

View File

@@ -49,7 +49,8 @@ export class WorkspaceUpgradeController {
checkIfNeedUpgrade() { checkIfNeedUpgrade() {
const needUpgrade = !!checkWorkspaceCompatibility( const needUpgrade = !!checkWorkspaceCompatibility(
this.workspace.blockSuiteWorkspace this.workspace.blockSuiteWorkspace,
this.workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD
); );
this.status = { this.status = {
...this.status, ...this.status,
@@ -69,7 +70,8 @@ export class WorkspaceUpgradeController {
await this.workspace.engine.sync.waitForSynced(); await this.workspace.engine.sync.waitForSynced();
const step = checkWorkspaceCompatibility( const step = checkWorkspaceCompatibility(
this.workspace.blockSuiteWorkspace this.workspace.blockSuiteWorkspace,
this.workspace.flavour === WorkspaceFlavour.AFFINE_CLOUD
); );
if (!step) { if (!step) {