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:
parent
d4a6eb26a4
commit
eb18991ddb
1 changed files with 5 additions and 0 deletions
|
@ -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"));
|
||||
|
|
Loading…
Add table
Reference in a new issue