Commit 72ec635d authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_ingestion: handle ingestion of modified files

parent 891e2bb3
...@@ -31,14 +31,23 @@ try: ...@@ -31,14 +31,23 @@ try:
if data_ingestion is not None: if data_ingestion is not None:
if data_ingestion.getSimulationState() != 'started': if data_ingestion.getSimulationState() != 'started':
# CHECK HASH modified = False
#if hash is equal: if size != None and size != "":
context.logEntry("An older ingestion for reference %s was already done." % data_ingestion_reference) data_stream = portal_catalog.getResultValue(
raise ValueError("An older ingestion for reference %s was already done." % data_ingestion_reference) portal_type = 'Data Stream',
#else: validation_state = 'validated',
#portal.ERP5Site_invalidateIngestionObjects(data_ingestion.getReference()) reference = data_ingestion_reference)
if size != data_stream.getSize():
#if data_ingestion is None: modified = True
elif hash_value != None and hash_value != "" and hash_value != data_stream.getVersion():
modified = True
if not modified:
context.logEntry("An older ingestion for reference %s was already done." % data_ingestion_reference)
raise ValueError("An older ingestion for reference %s was already done." % data_ingestion_reference)
else:
context.logEntry("Ingestion of modified file. Old version will be invalidated.")
portal.ERP5Site_invalidateIngestionObjects(data_ingestion_reference)
specialise_value_list = [x.getObject() for x in portal_catalog.searchResults( specialise_value_list = [x.getObject() for x in portal_catalog.searchResults(
portal_type = 'Data Supply', portal_type = 'Data Supply',
reference = 'embulk', reference = 'embulk',
......
...@@ -16,6 +16,7 @@ try: ...@@ -16,6 +16,7 @@ try:
# remove supplier and eof from reference # remove supplier and eof from reference
data_ingestion_reference = '/'.join(reference.split('/')[1:-3]) data_ingestion_reference = '/'.join(reference.split('/')[1:-3])
EOF = reference.split('/')[-3] EOF = reference.split('/')[-3]
size = reference.split('/')[-2]
if data_ingestion_reference is "": if data_ingestion_reference is "":
context.logEntry("[ERROR] Data Ingestion reference is not well formated") context.logEntry("[ERROR] Data Ingestion reference is not well formated")
...@@ -39,6 +40,9 @@ try: ...@@ -39,6 +40,9 @@ try:
pass pass
return FALSE return FALSE
if size != "" and size != None:
# this is a modified file
return FALSE
context.logEntry("[ERROR] Data Ingestion reference %s already exists" % data_ingestion_reference) context.logEntry("[ERROR] Data Ingestion reference %s already exists" % data_ingestion_reference)
return TRUE return TRUE
except Exception as e: except Exception as e:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment