@@ -178,18 +178,26 @@ def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None):
178178 if content_type is None :
179179 content_type = 99
180180
181+ output = conf .database_cursor .execute ("SELECT id, value FROM data WHERE taskid = ? AND status = ? AND content_type = ? LIMIT 0,1" ,
182+ (self .taskid , status , content_type ))
183+
181184 if status == CONTENT_STATUS .IN_PROGRESS :
182- output = conf .database_cursor .execute ("SELECT id, value FROM data WHERE taskid = ? AND status = ? AND content_type = ? LIMIT 0,1" ,
183- (self .taskid , status , content_type ))
185+ # Ignore all non-relevant messages
186+ if kb .partRun is None :
187+ return
184188
185189 if len (output ) == 0 :
186190 conf .database_cursor .execute ("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)" ,
187191 (self .taskid , status , content_type , jsonize (value )))
188192 else :
189- new_value = "%s%s" % (output [0 ][1 ], value )
193+ new_value = "%s%s" % (dejsonize ( output [0 ][1 ]) , value )
190194 conf .database_cursor .execute ("UPDATE data SET value = ? WHERE id = ?" ,
191195 (jsonize (new_value ), output [0 ][0 ]))
192196 else :
197+ if len (output ) > 0 :
198+ conf .database_cursor .execute ("DELETE FROM data WHERE taskid = ? AND status = %s AND content_type = ?" % CONTENT_STATUS .IN_PROGRESS ,
199+ (self .taskid , content_type ))
200+
193201 conf .database_cursor .execute ("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)" ,
194202 (self .taskid , status , content_type , jsonize (value )))
195203 else :
@@ -217,9 +225,6 @@ def emit(self, record):
217225
218226def setRestAPILog ():
219227 if hasattr (conf , "api" ):
220- #conf.database_connection = sqlite3.connect(conf.database, timeout=1, isolation_level=None)
221- #conf.database_cursor = conf.database_connection.cursor()
222-
223228 conf .database_cursor = Database (conf .database )
224229 conf .database_cursor .connect ("client" )
225230
0 commit comments