add delete + fix run_dev
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import close_old_connections
|
||||
|
||||
@@ -5,6 +7,7 @@ import time
|
||||
import signal
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import timedelta
|
||||
|
||||
from torrent.models import Torrent
|
||||
from torrent.utils import transmission_handler
|
||||
@@ -27,11 +30,20 @@ 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()
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
task_schedule = {
|
||||
"update_transmission_data": {
|
||||
"func": update_transmission_data,
|
||||
"schedule": 5.0
|
||||
},
|
||||
"clean_old_torrents": {
|
||||
"func": clean_old_torrents,
|
||||
"schedule": 60.0
|
||||
}
|
||||
}
|
||||
histories = {}
|
||||
|
||||
Reference in New Issue
Block a user