From f69fa747af1892d1ba1d0821d155d0489aacbd9d Mon Sep 17 00:00:00 2001 From: meeb Date: Mon, 15 Mar 2021 01:13:16 +1100 Subject: [PATCH] fix download cap date comparison check in signal, resolves #97 --- tubesync/sync/signals.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index 9a2ed86..6563188 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -101,20 +101,24 @@ def media_post_save(sender, instance, created, **kwargs): if not instance.downloaded: max_cap_age = instance.source.download_cap_date published = instance.published - if not published and not instance.skip: - log.warn(f'Media: {instance.source} / {instance} has no published date ' - f'set, marking to be skipped') - instance.skip = True - cap_changed = True + if not published: + if not instance.skip: + log.warn(f'Media: {instance.source} / {instance} has no published date ' + f'set, marking to be skipped') + instance.skip = True + cap_changed = True + else: + log.debug(f'Media: {instance.source} / {instance} has no published date ' + f'set but is already marked to be skipped') else: if max_cap_age: - if instance.published > max_cap_age and instance.skip: + if published > max_cap_age and instance.skip: # Media was published after the cap date but is set to be skipped log.info(f'Media: {instance.source} / {instance} has a valid ' f'publishing date, marking to be unskipped') instance.skip = False cap_changed = True - elif instance.published <= max_cap_age and not instance.skip: + elif published <= max_cap_age and not instance.skip: log.info(f'Media: {instance.source} / {instance} is too old for ' f'the download cap date, marking to be skipped') instance.skip = True