corrected time record type, mismatch caused issues and kept credential verification from occuring

This commit is contained in:
Bryan Van Deusen
2026-01-26 22:51:03 -05:00
parent 204e8efcdc
commit d2e4d6c588
4 changed files with 19 additions and 14 deletions
+9 -8
View File
@@ -11,6 +11,7 @@ from sqlalchemy.orm import selectinload
from app.config import get_settings
from app.tasks.celery_app import celery_app
from app.models.base import utcnow
from app.models.source import Source
from app.models.subscription import Subscription
from app.models.download import Download, DownloadStatus, ErrorType as DBErrorType
@@ -77,7 +78,7 @@ async def _download_source_async(source_id: int) -> dict:
source_id=source.id,
url=source.url,
status=DownloadStatus.RUNNING,
started_at=datetime.utcnow(),
started_at=utcnow(),
)
session.add(download)
await session.commit()
@@ -123,7 +124,7 @@ async def _download_source_async(source_id: int) -> dict:
)
# Update download record
download.completed_at = datetime.utcnow()
download.completed_at = utcnow()
download.file_count = dl_result.files_downloaded
download.metadata_ = {
"stdout": dl_result.stdout[:10000] if dl_result.stdout else None, # Truncate
@@ -133,7 +134,7 @@ async def _download_source_async(source_id: int) -> dict:
if dl_result.success:
download.status = DownloadStatus.COMPLETED
source.last_success = datetime.utcnow()
source.last_success = utcnow()
source.error_count = 0
logger.info(f"Download completed for {subscription_name}/{source.platform}: {dl_result.files_downloaded} files")
@@ -164,7 +165,7 @@ async def _download_source_async(source_id: int) -> dict:
})
# Update source last_check
source.last_check = datetime.utcnow()
source.last_check = utcnow()
await session.commit()
return {
@@ -183,9 +184,9 @@ async def _download_source_async(source_id: int) -> dict:
download.status = DownloadStatus.FAILED
download.error_type = DBErrorType.UNKNOWN_ERROR
download.error_message = str(e)
download.completed_at = datetime.utcnow()
download.completed_at = utcnow()
source.error_count = (source.error_count or 0) + 1
source.last_check = datetime.utcnow()
source.last_check = utcnow()
await session.commit()
@@ -219,7 +220,7 @@ async def _scheduled_check_async() -> dict:
try:
async with session_factory() as session:
now = datetime.utcnow()
now = utcnow()
# Find sources due for checking:
# - enabled = True
@@ -286,7 +287,7 @@ async def _cleanup_old_downloads_async() -> dict:
try:
async with session_factory() as session:
now = datetime.utcnow()
now = utcnow()
# Delete completed downloads older than 30 days
completed_cutoff = now - timedelta(days=30)