Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: make it clear if if resp content was not awaited

NTFSvolume2eae5f816b6a
diff --git a/cyberdrop_dl/clients/response.py b/cyberdrop_dl/clients/response.py
index 95ea83120..c8d345cb8 100644
--- a/cyberdrop_dl/clients/response.py
+++ b/cyberdrop_dl/clients/response.py
@@ -6,6 +6,7 @@ import datetime
import json
import logging
from abc import ABC, abstractmethod
+from enum import StrEnum
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Generic, Literal, Self, final, override
@@ -34,6 +35,8 @@ _ResponseT = TypeVar(
default=Any,
)
+EMPTY_CONTENT = StrEnum("ResponseContentPlaceHolder", [("EMPTY", "")]).EMPTY
+
@dataclasses.dataclass(slots=True, frozen=True)
class ContentDisposition:
@@ -67,7 +70,7 @@ class AbstractResponse(ABC, Generic[_ResponseT]):
id: str = dataclasses.field(init=False, default="")
_resp: _ResponseT
- _text: str = ""
+ _text: str = EMPTY_CONTENT
_cache: dict[str, Any] = dataclasses.field(init=False, compare=False, default_factory=dict)
_lock: asyncio.Lock = dataclasses.field(init=False, compare=False, default_factory=asyncio.Lock)
created_at: datetime.datetime = dataclasses.field(
@@ -98,6 +101,10 @@ class AbstractResponse(ABC, Generic[_ResponseT]):
except ValueError:
logger.exception("Unable to decode content of response %s", self.id)
content = "<ERROR DECODING CONTENT>"
+
+ if content is EMPTY_CONTENT:
+ content = "<DID NOT AWAIT FOR CONTENT>"
+
return {
"url": str(self.url),
"status_code": self.status,
@@ -309,7 +316,6 @@ class _AIOHTTPResponse(AbstractResponse[ClientResponse]):
headers=resp.headers,
url=url,
location=location,
- _text="",
_resp=resp,
)
@@ -350,7 +356,6 @@ class _CurlResponse(AbstractResponse[CurlResponse]):
headers=headers,
url=url,
location=location,
- _text="",
_resp=resp,
)