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:
if data_ingestion is not None:
if data_ingestion.getSimulationState() != 'started':
# CHECK HASH
#if hash is equal:
modified = False
if size != None and size != "":
data_stream = portal_catalog.getResultValue(
portal_type = 'Data Stream',
validation_state = 'validated',
reference = data_ingestion_reference)
if size != data_stream.getSize():
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:
#portal.ERP5Site_invalidateIngestionObjects(data_ingestion.getReference())
else:
context.logEntry("Ingestion of modified file. Old version will be invalidated.")
portal.ERP5Site_invalidateIngestionObjects(data_ingestion_reference)
#if data_ingestion is None:
specialise_value_list = [x.getObject() for x in portal_catalog.searchResults(
portal_type = 'Data Supply',
reference = 'embulk',
......
......@@ -16,6 +16,7 @@ try:
# remove supplier and eof from reference
data_ingestion_reference = '/'.join(reference.split('/')[1:-3])
EOF = reference.split('/')[-3]
size = reference.split('/')[-2]
if data_ingestion_reference is "":
context.logEntry("[ERROR] Data Ingestion reference is not well formated")
......@@ -39,6 +40,9 @@ try:
pass
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)
return TRUE
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