mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Make changes required for Desktop FS updates (#1099)
Make a set of changes required for Desktop FS improvements, see https://github.com/gristlabs/grist-desktop/pull/42 --------- Co-authored-by: Spoffy <contact@spoffy.net> Co-authored-by: Spoffy <4805393+Spoffy@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import {ActiveDoc} from 'app/server/lib/ActiveDoc';
|
||||
import {DummyAuthorizer} from 'app/server/lib/Authorizer';
|
||||
import {DocManager} from 'app/server/lib/DocManager';
|
||||
import {DocSession, makeExceptionalDocSession} from 'app/server/lib/DocSession';
|
||||
import {DocStorageManager} from 'app/server/lib/DocStorageManager';
|
||||
import {createDummyGristServer, GristServer} from 'app/server/lib/GristServer';
|
||||
import {IDocStorageManager} from 'app/server/lib/IDocStorageManager';
|
||||
import {getAppRoot} from 'app/server/lib/places';
|
||||
@@ -17,6 +16,7 @@ import * as fse from 'fs-extra';
|
||||
import {tmpdir} from 'os';
|
||||
import * as path from 'path';
|
||||
import * as tmp from 'tmp';
|
||||
import {create} from "app/server/lib/create";
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
|
||||
@@ -138,7 +138,7 @@ export async function createDocManager(
|
||||
server?: GristServer} = {}): Promise<DocManager> {
|
||||
// Set Grist home to a temporary directory, and wipe it out on exit.
|
||||
const tmpDir = options.tmpDir || await createTmpDir();
|
||||
const docStorageManager = options.storageManager || new DocStorageManager(tmpDir);
|
||||
const docStorageManager = options.storageManager || await create.createLocalDocStorageManager(tmpDir);
|
||||
const pluginManager = options.pluginManager || await getGlobalPluginManager();
|
||||
const store = getDocWorkerMap();
|
||||
const internalPermitStore = store.getPermitStore('1');
|
||||
|
||||
@@ -7,7 +7,12 @@ import {ActiveDoc} from 'app/server/lib/ActiveDoc';
|
||||
import {create} from 'app/server/lib/create';
|
||||
import {DocManager} from 'app/server/lib/DocManager';
|
||||
import {makeExceptionalDocSession} from 'app/server/lib/DocSession';
|
||||
import {DELETED_TOKEN, ExternalStorage, wrapWithKeyMappedStorage} from 'app/server/lib/ExternalStorage';
|
||||
import {
|
||||
DELETED_TOKEN,
|
||||
ExternalStorage, ExternalStorageCreator,
|
||||
ExternalStorageSettings,
|
||||
wrapWithKeyMappedStorage
|
||||
} from 'app/server/lib/ExternalStorage';
|
||||
import {createDummyGristServer} from 'app/server/lib/GristServer';
|
||||
import {
|
||||
BackupEvent,
|
||||
@@ -270,7 +275,7 @@ class TestStore {
|
||||
private _localDirectory: string,
|
||||
private _workerId: string,
|
||||
private _workers: DocWorkerMap,
|
||||
private _externalStorageCreate: (purpose: 'doc'|'meta', extraPrefix: string) => ExternalStorage|undefined) {
|
||||
private _externalStorageCreate: ExternalStorageCreator) {
|
||||
}
|
||||
|
||||
public async run<T>(fn: () => Promise<T>): Promise<T> {
|
||||
@@ -296,18 +301,20 @@ class TestStore {
|
||||
secondsBeforeFirstRetry: 3, // rumors online suggest delays of 10-11 secs
|
||||
// are not super-unusual.
|
||||
pushDocUpdateTimes: false,
|
||||
externalStorageCreator: (purpose) => {
|
||||
|
||||
};
|
||||
const externalStorageCreator = (purpose: ExternalStorageSettings["purpose"]) => {
|
||||
const result = this._externalStorageCreate(purpose, this._extraPrefix);
|
||||
if (!result) { throw new Error('no storage'); }
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
const storageManager = new HostedStorageManager(this._localDirectory,
|
||||
this._workerId,
|
||||
false,
|
||||
this._workers,
|
||||
dbManager,
|
||||
create,
|
||||
externalStorageCreator,
|
||||
options);
|
||||
this.storageManager = storageManager;
|
||||
this.docManager = new DocManager(storageManager, await getGlobalPluginManager(),
|
||||
|
||||
@@ -91,7 +91,7 @@ export class TestServer {
|
||||
...this._defaultEnv,
|
||||
...customEnv
|
||||
};
|
||||
const main = await testUtils.getBuildFile('app/server/mergedServerMain.js');
|
||||
const main = await testUtils.getBuildFile('app/server/MergedServer.js');
|
||||
this._server = spawn('node', [main, '--testingHooks'], {
|
||||
env,
|
||||
stdio: ['inherit', serverLog, serverLog]
|
||||
|
||||
Reference in New Issue
Block a user