Skip to content

Commit

Permalink
Merge pull request #27 from contentstack/hotfix/1.5.2
Browse files Browse the repository at this point in the history
Solve the bug of duplicate entry
  • Loading branch information
rohitmishra209 authored Apr 7, 2020
2 parents 1ea661f + e52f958 commit f8167b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 9 additions & 4 deletions lib/import/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ importEntries.prototype = {
});
});
});
}).catch(reject);
}).catch(function(error) {
return reject(error)
})
});
},

Expand Down Expand Up @@ -265,7 +267,11 @@ importEntries.prototype = {
return;
}).catch(function(error) {
if (error.hasOwnProperty('error_code') && error.error_code === 119) {
log.error('Error creating entry due to: ' + JSON.stringify(error));
if(error.errors.title) {
log.error('Entry ' + eUid +' already exist, skip to avoid creating a duplicate entry');
} else {
log.error('Error creating entry due to: ' + JSON.stringify(error));
}
self.createdEntriesWOUid.push({
content_type: ctUid,
locale: lang,
Expand Down Expand Up @@ -569,8 +575,7 @@ importEntries.prototype = {
helper.writeFile(_ePath, entries);
log.success('Completed mapping entry wo uid: ' + query.entry.uid + ': ' + response.body.entries[0].uid);
return resolve();
}).catch(function(error) {
log.error(error);
}).catch(function() {
return resolve();
});
});
Expand Down
8 changes: 5 additions & 3 deletions lib/util/supress-mandatory-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ var supress = module.exports = function (schema, flag) {

if ((schema[i].hasOwnProperty('mandatory') && schema[i].mandatory) || (schema[i].hasOwnProperty('unique') &&
schema[i].unique)) {
schema[i].unique = false;
schema[i].mandatory = false;
flag.supressed = true;
if(schema[i].uid !== 'title') {
schema[i].unique = false;
schema[i].mandatory = false;
flag.supressed = true;
}
}
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack-import",
"version": "1.5.1",
"version": "1.5.2",
"description": "Import data into Contentstack",
"homepage": "https://www.contentstack.com/docs/tools-and-frameworks/content-migration/within-contentstack",
"author": {
Expand Down

0 comments on commit f8167b1

Please sign in to comment.