(core) Remove transform columns on shutdown

Summary: Call a new user action `RemoveTransformColumns` in ActiveDoc shutdown.

Test Plan: Added nbrowser test

Reviewers: georgegevoian, paulfitz

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4107
This commit is contained in:
Alex Hall
2023-11-13 22:59:23 +02:00
parent 3dfe4be5f3
commit 5197891427
7 changed files with 84 additions and 22 deletions

View File

@@ -1994,6 +1994,14 @@ export class ActiveDoc extends EventEmitter {
// even if the doc is only ever opened briefly, without having to slow down startup.
await safeCallAndWait("removeUnusedAttachments", () => this.removeUnusedAttachments(true, usageOptions));
if (this._dataEngine && this._fullyLoaded) {
// Note that this must happen before `this._shuttingDown = true` because of this line in Sharing.ts:
// if (this._activeDoc.isShuttingDown && isCalculate) {
await safeCallAndWait("removeTransformColumns",
() => this.applyUserActions(docSession, [["RemoveTransformColumns"]])
);
}
// Update data size; we'll be syncing both it and attachments size to the database soon.
await safeCallAndWait("_updateDataSize", () => this._updateDataSize(usageOptions));
}

View File

@@ -8,7 +8,7 @@ import {
UserActionBundle
} from 'app/common/ActionBundle';
import {ApplyUAExtendedOptions} from 'app/common/ActiveDocAPI';
import {CALCULATING_USER_ACTIONS, DocAction, getNumRows, UserAction} from 'app/common/DocActions';
import {DocAction, getNumRows, SYSTEM_ACTIONS, UserAction} from 'app/common/DocActions';
import {allToken} from 'app/common/sharing';
import {GranularAccessForBundle} from 'app/server/lib/GranularAccess';
import log from 'app/server/lib/log';
@@ -246,7 +246,7 @@ export class Sharing {
try {
const isCalculate = (userActions.length === 1 && CALCULATING_USER_ACTIONS.has(userActions[0][0] as string));
const isCalculate = (userActions.length === 1 && SYSTEM_ACTIONS.has(userActions[0][0] as string));
// `internal` is true if users shouldn't be able to undo the actions. Applies to:
// - Calculate/UpdateCurrentTime because it's not considered as performed by a particular client.
// - Adding attachment metadata when uploading attachments,