Skip to content

Commit cff8c68

Browse files
committed
Fix missing file id in nested tables #196
* The file id is no longer in the returned file object when doing bulkCreate compared to just create. Fixed by manually setting the file id. Signed-off-by: Jillian Daguil <[email protected]>
1 parent 3fa3e52 commit cff8c68

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

assets/js/aboutCodeDB.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ class AboutCodeDB {
213213
if (rootPath === file.path) {
214214
hasRootPath = true;
215215
}
216+
file.id = index++;
216217
files.push(file);
217218
if (files.length >= batchSize) {
218219
// Need to set a new variable before handing to promise
219220
this.pause();
220221
promiseChain = promiseChain
221222
.then(() => that._batchCreateFiles(files, scancode.id))
222223
.then(() => {
223-
index += files.length;
224224
const files_count = scancode.files_count;
225225
const currProgress = Math.round(index/files_count*100);
226226
if (currProgress > progress) {
@@ -295,11 +295,6 @@ class AboutCodeDB {
295295
file.scancodeId = scancodeId;
296296
});
297297
return this.File.bulkCreate(files, options)
298-
.then((savedFiles) => {
299-
$.each(files, (i, file) => {
300-
file.id = savedFiles[i].id;
301-
});
302-
})
303298
.then(() => {
304299
let licenses = $.map(files, file => {
305300
return $.map(file.licenses || [], license => {

0 commit comments

Comments
 (0)