From eb18991ddb0e0dff6be2c3a007e281602e362561 Mon Sep 17 00:00:00 2001 From: David Arvelo Date: Thu, 8 May 2014 20:03:05 -0400 Subject: [PATCH] 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 --- core/server/api/db.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/server/api/db.js b/core/server/api/db.js index 8217f3c3ed..bdd6592894 100644 --- a/core/server/api/db.js +++ b/core/server/api/db.js @@ -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"));