fix download cap date comparison check in signal, resolves #97

This commit is contained in:
meeb 2021-03-15 01:13:16 +11:00
parent a29a92893f
commit f69fa747af
1 changed files with 11 additions and 7 deletions

View File

@ -101,20 +101,24 @@ def media_post_save(sender, instance, created, **kwargs):
if not instance.downloaded: if not instance.downloaded:
max_cap_age = instance.source.download_cap_date max_cap_age = instance.source.download_cap_date
published = instance.published published = instance.published
if not published and not instance.skip: if not published:
if not instance.skip:
log.warn(f'Media: {instance.source} / {instance} has no published date ' log.warn(f'Media: {instance.source} / {instance} has no published date '
f'set, marking to be skipped') f'set, marking to be skipped')
instance.skip = True instance.skip = True
cap_changed = 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: else:
if max_cap_age: 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 # Media was published after the cap date but is set to be skipped
log.info(f'Media: {instance.source} / {instance} has a valid ' log.info(f'Media: {instance.source} / {instance} has a valid '
f'publishing date, marking to be unskipped') f'publishing date, marking to be unskipped')
instance.skip = False instance.skip = False
cap_changed = True 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 ' log.info(f'Media: {instance.source} / {instance} is too old for '
f'the download cap date, marking to be skipped') f'the download cap date, marking to be skipped')
instance.skip = True instance.skip = True