2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 03:58:26 +00:00

fix: don't create copy if memory

This commit is contained in:
18alantom 2022-05-31 11:39:45 +05:30
parent 2dd3f9dab4
commit a89627e139
2 changed files with 10 additions and 2 deletions

View File

@ -63,10 +63,10 @@ export class DatabaseManager extends DatabaseDemuxBase {
} catch (err) {
console.error(err);
await this.db!.close();
await fs.copyFile(copyPath, dbPath);
copyPath && (await fs.copyFile(copyPath, dbPath));
throw err;
} finally {
await fs.unlink(copyPath);
copyPath && (await fs.unlink(copyPath));
}
}
@ -154,6 +154,10 @@ export class DatabaseManager extends DatabaseDemuxBase {
async #makeTempCopy() {
const src = this.db!.dbPath;
if (src === ':memory:') {
return null;
}
const dir = path.parse(src).dir;
const dest = path.join(dir, '__premigratory_temp.db');
await fs.copyFile(src, dest);

View File

@ -24,6 +24,10 @@ const defaultNumberSeriesMap = {
} as Record<ModelNameEnum, string>;
async function execute(dm: DatabaseManager) {
if (dm.db?.dbPath === ':memory:') {
return;
}
const sourceKnex = dm.db!.knex!;
const version = (
await sourceKnex('SingleValue')