0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Make DB Import backwards compatible

closes #2716
- Continues to parse and allow import with the old format
- Detects the presence of the new JSON-API format and allows import
This commit is contained in:
David Arvelo 2014-05-08 20:03:05 -04:00
parent d4a6eb26a4
commit eb18991ddb

View file

@ -63,6 +63,11 @@ db = {
// Parse the json data
try {
importData = JSON.parse(fileContents);
// if importData follows JSON-API format `{ db: [exportedData] }`
if (_.keys(importData).length === 1 && Array.isArray(importData.db)) {
importData = importData.db[0];
}
} catch (e) {
errors.logError(e, "API DB import content", "check that the import file is valid JSON.");
return when.reject(new Error("Failed to parse the import JSON file"));