From f0c6052c73b8b207b374de7f685a244917014895 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Mon, 24 Mar 2014 09:29:31 +0100 Subject: [PATCH] Unlink import file when finished fixes #2493 - Update db import version (in case it doesn't exist) - Properly unlink file after import or error --- core/server/api/db.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/server/api/db.js b/core/server/api/db.js index 117768197e..f3c59a17d0 100644 --- a/core/server/api/db.js +++ b/core/server/api/db.js @@ -38,7 +38,7 @@ db = { return api.settings.read({ key: 'databaseVersion' }).then(function (setting) { return when(setting.value); }, function () { - return when('001'); + return when('002'); }).then(function (version) { databaseVersion = version; // Read the file contents @@ -82,6 +82,9 @@ db = { return when.resolve({message: 'Posts, tags and other data successfully imported'}); }).otherwise(function importFailure(error) { return when.reject({code: 500, message: error.message || error}); + }).finally(function () { + // Unlink the file after import + return nodefn.call(fs.unlink, options.importfile.path); }); }, 'deleteAllContent': function () {