diff --git a/app/torrent/management/commands/torrent_event.py b/app/torrent/management/commands/torrent_event.py index 9c757f8..3b089c8 100644 --- a/app/torrent/management/commands/torrent_event.py +++ b/app/torrent/management/commands/torrent_event.py @@ -32,7 +32,9 @@ def update_transmission_data(): def clean_old_torrents(): expired_date = timezone.now() - timedelta(days=settings.TORRENT_TTL) - Torrent.objects.filter(date_created__lt=expired_date).first().delete() + torrent = Torrent.objects.filter(date_created__lt=expired_date).first() + if torrent: + torrent.delete() class Command(BaseCommand):