🤬
  • Dont even bother processing if the previous checksum and the just fetched one was the same

  • Loading...
  • dgtlmoon committed 2 years ago
    f15ec853
    1 parent 434c5813
  • ■ ■ ■ ■ ■ ■
    changedetectionio/content_fetcher.py
    skipped 20 lines
    21 21   self.page_text = html_tools.html_to_text(page_html)
    22 22   return
    23 23   
     24 +class checksumFromPreviousCheckWasTheSame(Exception):
     25 + def __init__(self):
     26 + return
    24 27   
    25 28  class JSActionExceptions(Exception):
    26 29   def __init__(self, status_code, url, screenshot, message=''):
    skipped 590 lines
  • ■ ■ ■ ■ ■ ■
    changedetectionio/fetch_site_status.py
    skipped 129 lines
    130 130   self.screenshot = fetcher.screenshot
    131 131   self.xpath_data = fetcher.xpath_data
    132 132   
     133 + # Do we even need to run at all?
     134 + update_obj['previous_md5_before_filters'] = hashlib.md5(fetcher.content.encode('utf-8')).hexdigest()
     135 + if update_obj['previous_md5_before_filters'] == watch.get('previous_md5_before_filters'):
     136 + raise content_fetcher.checksumFromPreviousCheckWasTheSame()
     137 + 
     138 + 
    133 139   # Fetching complete, now filters
    134 140   # @todo move to class / maybe inside of fetcher abstract base?
    135 141   
    skipped 184 lines
  • ■ ■ ■ ■ ■
    changedetectionio/model/Watch.py
    skipped 20 lines
    21 21   'last_viewed': 0, # history key value of the last viewed via the [diff] link
    22 22   #'newest_history_key': 0,
    23 23   'title': None,
     24 + 'previous_md5_before_filters': False, # Used for skipping changedetection entirely
    24 25   'previous_md5': False,
    25 26   'uuid': str(uuid_builder.uuid4()),
    26 27   'headers': {}, # Extra headers to send
    skipped 228 lines
  • ■ ■ ■ ■ ■ ■
    changedetectionio/update_worker.py
    skipped 210 lines
    211 211   
    212 212   process_changedetection_results = True
    213 213   
     214 + except content_fetcher.checksumFromPreviousCheckWasTheSame as e:
     215 + # Yes fine, so nothing todo
     216 + continue
     217 + 
    214 218   except content_fetcher.EmptyReply as e:
    215 219   # Some kind of custom to-str handler in the exception handler that does this?
    216 220   err_text = "EmptyReply - try increasing 'Wait seconds before extracting text', Status Code {}".format(e.status_code)
    skipped 88 lines
Please wait...
Page is in error, reload to recover