Skip to content

Commit

Permalink
chore: remove redundant function
Browse files Browse the repository at this point in the history
- use only date in backup filename
  • Loading branch information
18alantom committed Jul 13, 2023
1 parent 4672323 commit dbd3698
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions backend/database/manager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import BetterSQLite3 from 'better-sqlite3';
import fs from 'fs-extra';
import { DatabaseError } from 'fyo/utils/errors';
import path from 'path';
import { DatabaseDemuxBase, DatabaseMethod } from 'utils/db/types';
import { getMapFromList } from 'utils/index';
import { Version } from 'utils/version';
import { getSchemas } from '../../schemas';
import { checkFileAccess, databaseMethodSet, unlinkIfExists } from '../helpers';
import { databaseMethodSet, unlinkIfExists } from '../helpers';
import patches from '../patches';
import { BespokeQueries } from './bespoke';
import DatabaseCore from './core';
import { runPatches } from './runPatch';
import { BespokeFunction, Patch } from './types';
import BetterSQLite3 from 'better-sqlite3';
import { getMapFromList } from 'utils/index';
import { Version } from 'utils/version';

export class DatabaseManager extends DatabaseDemuxBase {
db?: DatabaseCore;
Expand Down Expand Up @@ -61,24 +61,6 @@ export class DatabaseManager extends DatabaseDemuxBase {
await this.#executeMigration();
}

async #handleFailedMigration(
error: unknown,
dbPath: string,
copyPath: string | null
) {
await this.db!.close();

if (copyPath && (await checkFileAccess(copyPath))) {
await fs.copyFile(copyPath, dbPath);
}

if (error instanceof Error) {
error.message = `failed migration\n${error.message}`;
}

throw error;
}

async #executeMigration() {
const version = await this.#getAppVersion();
const patches = await this.#getPatchesToExecute(version);
Expand Down Expand Up @@ -214,7 +196,7 @@ export class DatabaseManager extends DatabaseDemuxBase {
}

const backupFolder = path.join(path.dirname(dbPath), 'backups');
const date = new Date().toISOString().split('.')[0];
const date = new Date().toISOString().split('T')[0];
const version = await this.#getAppVersion();
const backupFile = `${fileName}-${version}-${date}.books.db`;
fs.ensureDirSync(backupFolder);
Expand Down

0 comments on commit dbd3698

Please sign in to comment.