From 405d097024a0f4e7bc90dbb7b76a2fe5baa8dbb9 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Thu, 25 May 2023 16:26:48 +0200 Subject: [PATCH] fix: [crawler] fix undefined capture status --- bin/lib/crawlers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/lib/crawlers.py b/bin/lib/crawlers.py index d8f4c890..7dbb18b2 100755 --- a/bin/lib/crawlers.py +++ b/bin/lib/crawlers.py @@ -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())