mirror of
https://github.com/frappe/books.git
synced 2024-12-22 19:09:01 +00:00
fix: purgeCache, close db
This commit is contained in:
parent
48be520b20
commit
5c5dc09d58
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
@ -107,7 +107,7 @@ export class AuthHandler {
|
||||
// TODO: Implement this with auth flow
|
||||
}
|
||||
|
||||
purgeCache() {}
|
||||
async purgeCache() {}
|
||||
|
||||
#getServerURL() {
|
||||
return this.#config.serverURL || '';
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ export class DocHandler {
|
||||
this.observer = new Observable();
|
||||
}
|
||||
|
||||
purgeCache() {
|
||||
async purgeCache() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
@ -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 = {
|
||||
|
@ -34,7 +34,7 @@ describe('Fyo Init', function () {
|
||||
true,
|
||||
'non zero schemas'
|
||||
);
|
||||
await fyo.db.close();
|
||||
await fyo.db.purgeCache();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
|
@ -11,7 +11,7 @@ async function closeDbIfConnected() {
|
||||
return;
|
||||
}
|
||||
|
||||
await fyo.db.close();
|
||||
await fyo.db.purgeCache();
|
||||
}
|
||||
|
||||
export async function initializeInstance(
|
||||
|
@ -299,7 +299,7 @@ export default {
|
||||
);
|
||||
|
||||
updateConfigFiles(fyo);
|
||||
fyo.purgeCache();
|
||||
await fyo.purgeCache();
|
||||
await this.setFiles();
|
||||
|
||||
this.creatingDemo = false;
|
||||
|
Loading…
Reference in New Issue
Block a user