mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Changed backup service signature to be able to expand it
- Will need to add a new method allowing to read an export file, so the module signature has to become an object rather than a function
This commit is contained in:
parent
afe11c2b06
commit
49983e799c
5 changed files with 13 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
const Promise = require('bluebird');
|
||||
const backupDatabase = require('../../data/db/backup');
|
||||
const dbBackup = require('../../data/db/backup');
|
||||
const exporter = require('../../data/exporter');
|
||||
const importer = require('../../data/importer');
|
||||
const common = require('../../lib/common');
|
||||
|
@ -25,7 +25,7 @@ module.exports = {
|
|||
// NOTE: we need to have `include` property available as backupDatabase uses it internally
|
||||
Object.assign(frame.options, {include: frame.options.withRelated});
|
||||
|
||||
return backupDatabase(frame.options);
|
||||
return dbBackup.backup(frame.options);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -114,7 +114,7 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
return backupDatabase().then(deleteContent);
|
||||
return dbBackup.backup().then(deleteContent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const Promise = require('bluebird');
|
||||
const common = require('../../lib/common');
|
||||
const backupDatabase = require('../../data/db/backup');
|
||||
const dbBackup = require('../../data/db/backup');
|
||||
const models = require('../../models');
|
||||
const permissionsService = require('../../services/permissions');
|
||||
const ALLOWED_INCLUDES = ['count.posts', 'permissions', 'roles', 'roles.permissions'];
|
||||
|
@ -122,7 +122,7 @@ module.exports = {
|
|||
},
|
||||
permissions: true,
|
||||
async query(frame) {
|
||||
const filename = await backupDatabase();
|
||||
const filename = await dbBackup.backup();
|
||||
|
||||
return models.Base.transaction((t) => {
|
||||
frame.options.transacting = t;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const Promise = require('bluebird');
|
||||
const backupDatabase = require('../../data/db/backup');
|
||||
const dbBackup = require('../../data/db/backup');
|
||||
const exporter = require('../../data/exporter');
|
||||
const importer = require('../../data/importer');
|
||||
const common = require('../../lib/common');
|
||||
|
@ -25,7 +25,7 @@ module.exports = {
|
|||
// NOTE: we need to have `include` property available as backupDatabase uses it internally
|
||||
Object.assign(frame.options, {include: frame.options.withRelated});
|
||||
|
||||
return backupDatabase(frame.options);
|
||||
return dbBackup.backup(frame.options);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -114,7 +114,7 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
return backupDatabase().then(deleteContent);
|
||||
return dbBackup.backup().then(deleteContent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -39,4 +39,6 @@ backup = function backup(options) {
|
|||
});
|
||||
};
|
||||
|
||||
module.exports = backup;
|
||||
module.exports = {
|
||||
backup
|
||||
};
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
var should = require('should'),
|
||||
sinon = require('sinon'),
|
||||
rewire = require('rewire'),
|
||||
_ = require('lodash'),
|
||||
fs = require('fs-extra'),
|
||||
models = require('../../../../server/models'),
|
||||
exporter = require('../../../../server/data/exporter'),
|
||||
backupDatabase = rewire('../../../../server/data/db/backup');
|
||||
backupDatabase = require('../../../../server/data/db/backup');
|
||||
|
||||
describe('Backup', function () {
|
||||
var exportStub, filenameStub, fsStub;
|
||||
|
@ -25,7 +24,7 @@ describe('Backup', function () {
|
|||
});
|
||||
|
||||
it('should create a backup JSON file', function (done) {
|
||||
backupDatabase().then(function () {
|
||||
backupDatabase.backup().then(function () {
|
||||
exportStub.calledOnce.should.be.true();
|
||||
filenameStub.calledOnce.should.be.true();
|
||||
fsStub.calledOnce.should.be.true();
|
||||
|
|
Loading…
Add table
Reference in a new issue