Skip to content

Commit

Permalink
Unlink import file when finished
Browse files Browse the repository at this point in the history
fixes TryGhost#2493
- Update db import version (in case it doesn't exist)
- Properly unlink file after import or error
  • Loading branch information
halfdan committed Mar 24, 2014
1 parent ae3c367 commit f0c6052
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/server/api/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit f0c6052

Please sign in to comment.