Skip to content

Commit 6e4538a

Browse files
committed
#66: Fixed JSON import with saved components
* No longer creates a root with file information if one already exists from a previously exported JSON file. Signed-off-by: Jillian Daguil <[email protected]>
1 parent f60befb commit 6e4538a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

assets/js/renderer.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,23 @@ $(document).ready(function () {
435435
// Add root directory into data
436436
// See https://github.com/nexB/scancode-toolkit/issues/543
437437
const rootPath = json.files[0].path.split("/")[0];
438-
json.files.push({
439-
path: rootPath,
440-
name: rootPath,
441-
type: "directory",
442-
files_count: json.files_count
443-
});
438+
let hasRootPath = false;
439+
440+
for (let i = 0, n = json.files.length; i < n; i++) {
441+
if (rootPath === json.files[i].path) {
442+
hasRootPath = true;
443+
break;
444+
}
445+
}
446+
447+
if (!hasRootPath) {
448+
json.files.push({
449+
path: rootPath,
450+
name: rootPath,
451+
type: "directory",
452+
files_count: json.files_count
453+
});
454+
}
444455

445456
// Immediately ask for a SQLite to save and create the database
446457
dialog.showSaveDialog(

0 commit comments

Comments
 (0)