Skip to content

Commit 84489de

Browse files
committed
Sucessfully import scanfiles without --info option
Addresses: #385 Signed-off-by: Steven Esser <[email protected]>
1 parent 3dabdcf commit 84489de

File tree

3 files changed

+1865
-8
lines changed

3 files changed

+1865
-8
lines changed

assets/app/js/workbenchDB.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
const Sequelize = require('sequelize');
1818
const fs = require('fs');
19+
const path = require('path');
1920
const JSONStream = require('JSONStream');
2021
const Database = require('./models/database');
2122
const {parentPath} = require('./models/databaseUtils');
@@ -185,9 +186,15 @@ class WorkbenchDB {
185186
.then((db) => db.File.findAll(query))
186187
.then((files) => {
187188
return files.map((file) => {
189+
let file_name;
190+
if (!file.name) {
191+
file_name = path.basename(file.path);
192+
} else {
193+
file_name = file.name;
194+
}
188195
return {
189196
id: file.path,
190-
text: file.name,
197+
text: file_name,
191198
parent: file.parent,
192199
type: this.determineJSTreeType(file, promises),
193200
children: file.type === 'directory'
@@ -290,11 +297,6 @@ class WorkbenchDB {
290297
};
291298
}
292299

293-
// Show error for scans missing file type information
294-
if (header.scancode_options['--info'] === undefined) {
295-
reject(new WorkbenchDB.MissingFileInfoError());
296-
}
297-
298300
$.extend(header, {
299301
workbench_version: version,
300302
workbench_notice: 'Exported from ScanCode Workbench and provided on an "AS IS" BASIS, WITHOUT WARRANTIES\\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\\nScanCode Workbench should be considered or used as legal advice. Consult an Attorney\\nfor any legal advice.\\nScanCode Workbench is a free software analysis application from nexB Inc. and others.\\nVisit https://github.com/nexB/scancode-workbench/ for support and download."'
@@ -510,6 +512,4 @@ class WorkbenchDB {
510512
}
511513
}
512514

513-
WorkbenchDB.MissingFileInfoError = class MissingFileInfoError extends Error {};
514-
515515
module.exports = WorkbenchDB;

0 commit comments

Comments
 (0)