mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
fix: manually trigger temp db migration file cleanup
otherwise it wont happen until exit
This commit is contained in:
@@ -23,7 +23,7 @@ export class DatabaseCopyMigrator {
|
|||||||
constructor(private dbAccess: DBAccess) {}
|
constructor(private dbAccess: DBAccess) {}
|
||||||
|
|
||||||
async migrate(currentDbPath: string, migrateTo?: string) {
|
async migrate(currentDbPath: string, migrateTo?: string) {
|
||||||
const { path: tmpPath } = await tmp.file({ keep: false });
|
const { path: tmpPath, cleanup } = await tmp.file({ keep: false });
|
||||||
this.logger.debug('Migrating to temp DB %s', tmpPath);
|
this.logger.debug('Migrating to temp DB %s', tmpPath);
|
||||||
const tempDBConn = this.dbAccess.getOrCreateConnection(tmpPath);
|
const tempDBConn = this.dbAccess.getOrCreateConnection(tmpPath);
|
||||||
const tempDB = tempDBConn.kysely;
|
const tempDB = tempDBConn.kysely;
|
||||||
@@ -79,6 +79,7 @@ export class DatabaseCopyMigrator {
|
|||||||
await this.dbAccess.closeConnection(tmpPath);
|
await this.dbAccess.closeConnection(tmpPath);
|
||||||
await this.dbAccess.closeConnection(currentDbPath);
|
await this.dbAccess.closeConnection(currentDbPath);
|
||||||
await fs.cp(tmpPath, currentDbPath);
|
await fs.cp(tmpPath, currentDbPath);
|
||||||
|
await cleanup();
|
||||||
// Force reinit at the new path
|
// Force reinit at the new path
|
||||||
this.dbAccess.setConnection(currentDbPath);
|
this.dbAccess.setConnection(currentDbPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user