2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

fix: purgeCache, close db

This commit is contained in:
18alantom 2022-07-30 16:33:09 +05:30
parent 48be520b20
commit 5c5dc09d58
10 changed files with 17 additions and 17 deletions

View File

@ -2,7 +2,7 @@ import {
CannotCommitError,
getDbError,
NotFoundError,
ValueError
ValueError,
} from 'fyo/utils/errors';
import { knex, Knex } from 'knex';
import {
@ -11,12 +11,12 @@ import {
RawValue,
Schema,
SchemaMap,
TargetField
TargetField,
} from '../../schemas/types';
import {
getIsNullOrUndef,
getRandomString,
getValueMapFromList
getValueMapFromList,
} from '../../utils';
import { DatabaseBase, GetAllOptions, QueryFilter } from '../../utils/db/types';
import { getDefaultMetaFieldValueMap, sqliteTypeMap, SYSTEM } from '../helpers';
@ -24,7 +24,7 @@ import {
ColumnDiff,
FieldValueMap,
GetQueryBuilderOptions,
SingleValue
SingleValue,
} from './types';
/**

View File

@ -29,7 +29,7 @@ export async function setupDummyInstance(
baseCount: number = 1000,
notifier?: Notifier
) {
fyo.purgeCache();
await fyo.purgeCache();
notifier?.(fyo.t`Setting Up Instance`, -1);
const options = {
logo: null,

View File

@ -107,7 +107,7 @@ export class AuthHandler {
// TODO: Implement this with auth flow
}
purgeCache() {}
async purgeCache() {}
#getServerURL() {
return this.#config.serverURL || '';

View File

@ -85,7 +85,8 @@ export class DatabaseHandler extends DatabaseBase {
}
}
purgeCache() {
async purgeCache() {
await this.close();
this.dbPath = undefined;
this.#schemaMap = {};
this.fieldValueMap = {};
@ -214,7 +215,6 @@ export class DatabaseHandler extends DatabaseBase {
async close(): Promise<void> {
await this.#demux.call('close');
this.purgeCache();
}
/**

View File

@ -26,7 +26,7 @@ export class DocHandler {
this.observer = new Observable();
}
purgeCache() {
async purgeCache() {
this.init();
}

View File

@ -202,7 +202,7 @@ export class Fyo {
return value;
}
purgeCache() {
async purgeCache() {
this.pesa = getMoneyMaker({
currency: DEFAULT_CURRENCY,
precision: DEFAULT_INTERNAL_PRECISION,
@ -216,9 +216,9 @@ export class Fyo {
this.currencySymbols = {};
this.errorLog = [];
this.temp = {};
this.db.purgeCache();
this.auth.purgeCache();
this.doc.purgeCache();
await this.db.purgeCache();
await this.auth.purgeCache();
await this.doc.purgeCache();
}
store = {

View File

@ -34,7 +34,7 @@ describe('Fyo Init', function () {
true,
'non zero schemas'
);
await fyo.db.close();
await fyo.db.purgeCache();
});
});

View File

@ -149,7 +149,7 @@ export default {
async showDbSelector() {
fyo.config.set('lastSelectedFilePath', null);
fyo.telemetry.stop();
fyo.purgeCache();
await fyo.purgeCache();
this.activeScreen = 'DatabaseSelector';
this.dbPath = '';
this.searcher = null;

View File

@ -11,7 +11,7 @@ async function closeDbIfConnected() {
return;
}
await fyo.db.close();
await fyo.db.purgeCache();
}
export async function initializeInstance(

View File

@ -299,7 +299,7 @@ export default {
);
updateConfigFiles(fyo);
fyo.purgeCache();
await fyo.purgeCache();
await this.setFiles();
this.creatingDemo = false;