fix: [crawler] fix undefined capture status

This commit is contained in:
Terrtia 2023-05-25 16:26:48 +02:00
parent 9a4feb93a0
commit 405d097024
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -1091,7 +1091,10 @@ class CrawlerCapture:
return self.get_task().get_start_time()
def get_status(self):
return r_cache.hget(f'crawler:capture:{self.uuid}', 'status')
status = r_cache.hget(f'crawler:capture:{self.uuid}', 'status')
if not status:
status = -1
return status
def is_ongoing(self):
return self.get_status() == CaptureStatus.ONGOING
@ -1109,7 +1112,7 @@ class CrawlerCapture:
def update(self, status):
# Error or Reload
if not status:
r_cache.hset(f'crawler:capture:{self.uuid}', 'status', CaptureStatus.UNKNOWN)
r_cache.hset(f'crawler:capture:{self.uuid}', 'status', CaptureStatus.UNKNOWN.value)
r_cache.zadd('crawler:captures', {self.uuid: 0})
else:
last_check = int(time.time())