Skip to content

Commit f890258

Browse files
committed
Release 2.2.7
1 parent 15fd1d1 commit f890258

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mage-db-sync",
3-
"version": "2.2.6",
3+
"version": "2.2.7",
44
"description": "Database synchronizer for Magento, based on Magerun",
55
"license": "MIT",
66
"author": {
@@ -35,6 +35,7 @@
3535
],
3636
"scripts": {
3737
"build": "tsc",
38+
"watch": "tsc --watch",
3839
"prepare": "npm run build",
3940
"postinstall": "node scripts/postinstall.js",
4041
"migrate-config": "node scripts/migrate-config.js",

src/tasks/ImportTask.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ class ImportTask {
340340
// Import the database using magerun2 db:import
341341
await this.importDatabase(task, config, sqlFilePath, sqlFileSize);
342342

343+
// Store the imported file path for cleanup
344+
ctx.importedSqlFile = sqlFilePath;
345+
343346
const duration = Date.now() - startTime;
344347
const formattedDuration = ProgressDisplay.formatDuration(duration);
345348

@@ -356,18 +359,24 @@ class ImportTask {
356359
const logger = this.services.getLogger();
357360
task.output = 'Removing temporary SQL files...';
358361

359-
// Clean up SQL files (both compressed and uncompressed)
360-
const cleanupFiles = `${config.serverVariables.databaseName}.sql ${config.serverVariables.databaseName}.sql.gz`;
361-
362-
await localhostMagentoRootExec(
363-
`rm -f ${cleanupFiles}`,
364-
config,
365-
true
366-
);
367-
368-
logger.info('Cleanup complete', {
369-
removed: cleanupFiles
370-
});
362+
// Clean up the actual imported SQL file
363+
if (ctx.importedSqlFile && fs.existsSync(ctx.importedSqlFile)) {
364+
fs.unlinkSync(ctx.importedSqlFile);
365+
logger.info('Cleanup complete', {
366+
removed: ctx.importedSqlFile
367+
});
368+
} else {
369+
// Fallback: try to clean up based on database name (legacy behavior)
370+
const cleanupFiles = `${config.serverVariables.databaseName}.sql ${config.serverVariables.databaseName}.sql.gz`;
371+
await localhostMagentoRootExec(
372+
`rm -f ${cleanupFiles}`,
373+
config,
374+
true
375+
);
376+
logger.info('Cleanup complete (fallback)', {
377+
removed: cleanupFiles
378+
});
379+
}
371380

372381
task.output = 'Cleanup complete ✓';
373382
}

0 commit comments

Comments
 (0)