mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
committed by
Rainer Killinger
parent
18359fdab3
commit
2259da317a
@@ -485,14 +485,15 @@ export class Elasticsearch implements Database {
|
||||
|
||||
const item = await this.getObject(object.uid);
|
||||
|
||||
// we have to check that the item will get replaced if the index is rolled over
|
||||
// check that the item will get replaced if the index is rolled over (index with the same name excluding ending uid)
|
||||
if (typeof item !== 'undefined') {
|
||||
const indexOfNew = Elasticsearch.getIndex(obj.type, bulk.source, bulk);
|
||||
const oldIndex = item._index;
|
||||
|
||||
// new item doesn't replace the old one
|
||||
if (oldIndex.substring(0, oldIndex.length - Elasticsearch.INDEX_UID_LENGTH + 1)
|
||||
!== indexOfNew.substring(0, indexOfNew.length - Elasticsearch.INDEX_UID_LENGTH + 1)) {
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
if (oldIndex.substring(0, oldIndex.lastIndexOf('_'))
|
||||
!== indexOfNew.substring(0, indexOfNew.lastIndexOf('_'))) {
|
||||
throw new Error(
|
||||
// tslint:disable-next-line: no-magic-numbers
|
||||
`Object "${obj.uid}" already exists. Object was: ${JSON.stringify(obj, null, 2)}`,
|
||||
|
||||
Reference in New Issue
Block a user