better time usings
This commit is contained in:
@@ -11,7 +11,7 @@ import json
|
||||
import uuid
|
||||
from collections import deque
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Callable, Dict, List, Optional
|
||||
|
||||
@@ -183,7 +183,7 @@ class DownloadService:
|
||||
item.model_dump(mode="json")
|
||||
for item in self._failed_items
|
||||
],
|
||||
"timestamp": datetime.utcnow().isoformat(),
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
|
||||
with open(self._persistence_path, "w", encoding="utf-8") as f:
|
||||
@@ -225,7 +225,7 @@ class DownloadService:
|
||||
episode=episode,
|
||||
status=DownloadStatus.PENDING,
|
||||
priority=priority,
|
||||
added_at=datetime.utcnow(),
|
||||
added_at=datetime.now(timezone.utc),
|
||||
)
|
||||
|
||||
# Insert based on priority
|
||||
@@ -284,7 +284,7 @@ class DownloadService:
|
||||
if item_id in self._active_downloads:
|
||||
item = self._active_downloads[item_id]
|
||||
item.status = DownloadStatus.CANCELLED
|
||||
item.completed_at = datetime.utcnow()
|
||||
item.completed_at = datetime.now(timezone.utc)
|
||||
self._failed_items.append(item)
|
||||
del self._active_downloads[item_id]
|
||||
removed_ids.append(item_id)
|
||||
@@ -673,7 +673,7 @@ class DownloadService:
|
||||
try:
|
||||
# Update status
|
||||
item.status = DownloadStatus.DOWNLOADING
|
||||
item.started_at = datetime.utcnow()
|
||||
item.started_at = datetime.now(timezone.utc)
|
||||
self._active_downloads[item.id] = item
|
||||
|
||||
logger.info(
|
||||
@@ -715,7 +715,7 @@ class DownloadService:
|
||||
# Handle result
|
||||
if success:
|
||||
item.status = DownloadStatus.COMPLETED
|
||||
item.completed_at = datetime.utcnow()
|
||||
item.completed_at = datetime.now(timezone.utc)
|
||||
|
||||
# Track downloaded size
|
||||
if item.progress and item.progress.downloaded_mb:
|
||||
@@ -757,7 +757,7 @@ class DownloadService:
|
||||
except Exception as e:
|
||||
# Handle failure
|
||||
item.status = DownloadStatus.FAILED
|
||||
item.completed_at = datetime.utcnow()
|
||||
item.completed_at = datetime.now(timezone.utc)
|
||||
item.error = str(e)
|
||||
self._failed_items.append(item)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user