add delete + fix run_dev

This commit is contained in:
2025-09-06 09:31:20 +02:00
parent 5c3c864a9e
commit c7b09b30bd
3 changed files with 14 additions and 1 deletions

View File

@@ -254,3 +254,4 @@ TRANSMISSION = {
"username": getenv("TRANSMISSION_USERNAME"),
"password": getenv("TRANSMISSION_PASSWORD")
}
TORRENT_TTL = int(getenv("TORRENT_TTL", 90*24*60*60)) # 90 jours

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
CORES=$(nproc)
WORKERS=$((2 * CORES + 1))

View File

@@ -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 = {}