Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: use binary instead of decimal units for bytes

NTFSvolumeef4395380e2b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70ffe9223..2a6d5e1aa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,7 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
-- Create URLs.txt in interactive mode if it does not exists
+- In interactive mode, create `URLs.txt` if it does not exists
+- Use binary units instead of decimal units for file sizes
## [10.0.0] - 2026-06-28
diff --git a/cyberdrop_dl/config/__init__.py b/cyberdrop_dl/config/__init__.py
index fab9b9e4e..70b4bce3d 100644
--- a/cyberdrop_dl/config/__init__.py
+++ b/cyberdrop_dl/config/__init__.py
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
from collections.abc import Iterable
-MIN_REQUIRED_FREE_SPACE = to_bytesize("512MB")
+MIN_REQUIRED_FREE_SPACE = to_bytesize("512MiB")
MODULE_PATH = Path(__file__).parent
logger = logging.getLogger(__name__)
_app: App | None = None
@@ -92,7 +92,7 @@ class Config(ConfigModel, title="cyberdrop-dl config"):
"Max number of nested folders CDL will create when maximum_thread_depth is greater that 0"
min_free_space: Annotated[ByteSizeSerilized, AfterValidator(lambda x: max(x, MIN_REQUIRED_FREE_SPACE))] = (
- to_bytesize("5GB")
+ to_bytesize("5GiB")
)
"Minimum free space require to start new downloads"
diff --git a/cyberdrop_dl/config/default.yaml b/cyberdrop_dl/config/default.yaml
index c57aea664..b8b404f27 100644
--- a/cyberdrop_dl/config/default.yaml
+++ b/cyberdrop_dl/config/default.yaml
@@ -120,7 +120,7 @@ max_file_name_length: 95
max_folder_name_length: 60
max_thread_depth: 0
max_thread_folder_depth: null
-min_free_space: 5.0GB
+min_free_space: 5.0GiB
mtime: true
network:
connection_timeout: 15.0
diff --git a/cyberdrop_dl/config/schema.json b/cyberdrop_dl/config/schema.json
index 16a164311..098f63806 100644
--- a/cyberdrop_dl/config/schema.json
+++ b/cyberdrop_dl/config/schema.json
@@ -1174,7 +1174,7 @@
},
"min_free_space": {
"$ref": "#/$defs/ByteSizeSerilized",
- "default": 5000000000
+ "default": 5368709120
},
"mtime": {
"default": true,
diff --git a/cyberdrop_dl/manager.py b/cyberdrop_dl/manager.py
index 494fc10c6..f292471c5 100644
--- a/cyberdrop_dl/manager.py
+++ b/cyberdrop_dl/manager.py
@@ -8,8 +8,6 @@ import sys
import time
from typing import TYPE_CHECKING, Any, Self, final
-from pydantic.types import ByteSize
-
from cyberdrop_dl import ALL_DEPENDENCIES, __version__, aio, env, ffmpeg, stats
from cyberdrop_dl.cache import cache_context
from cyberdrop_dl.clients.downloads import DownloadClient
@@ -21,6 +19,7 @@ from cyberdrop_dl.database import Database
from cyberdrop_dl.dedupe import Czkawka
from cyberdrop_dl.hasher import Hasher
from cyberdrop_dl.logs import capture_logs, log_spacer
+from cyberdrop_dl.models.validators import bytesize_to_str
from cyberdrop_dl.progress import REFRESH_RATE, TUI_DISABLED
from cyberdrop_dl.sorter import Sorter
from cyberdrop_dl.utils import enter_context, get_system_information
@@ -139,7 +138,7 @@ class Manager:
def __print_stats(self, scrape_stats: ScrapeStats) -> None:
elapsed = datetime.timedelta(seconds=int(time.monotonic() - scrape_stats.start_time))
- total_data_written = ByteSize(self.scrape_mapper.tui.downloads.bytes_downloaded).human_readable(decimal=True)
+ total_data_written = bytesize_to_str(self.scrape_mapper.tui.downloads.bytes_downloaded)
logger.info("Run Stats:", extra={"color": "cyan"})
logger.info(f" Config file: {self.config.source}")
@@ -196,7 +195,7 @@ def _log_database(path: Path) -> None:
except FileNotFoundError:
db_size = 0
- logger.debug("Database file: %s (%s)", path, ByteSize(db_size).human_readable(decimal=True))
+ logger.debug("Database file: %s (%s)", path, bytesize_to_str(db_size))
def _log_enviroment() -> None:
diff --git a/cyberdrop_dl/models/validators/__init__.py b/cyberdrop_dl/models/validators/__init__.py
index 4beca53ed..b80b3d0ea 100644
--- a/cyberdrop_dl/models/validators/__init__.py
+++ b/cyberdrop_dl/models/validators/__init__.py
@@ -21,7 +21,7 @@ type _ConvertibleToInt = str | SupportsInt | SupportsIndex
def bytesize_to_str(value: _ConvertibleToInt) -> str:
- return ByteSize(value).human_readable(decimal=True)
+ return ByteSize(value).human_readable()
def to_yarl_url(value: object) -> yarl.URL:
diff --git a/cyberdrop_dl/scrape_mapper.py b/cyberdrop_dl/scrape_mapper.py
index d1478a8bc..8841f6fd3 100644
--- a/cyberdrop_dl/scrape_mapper.py
+++ b/cyberdrop_dl/scrape_mapper.py
@@ -8,13 +8,12 @@ import time
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Self
-from pydantic.types import ByteSize
-
from cyberdrop_dl import env, filepath, storage
from cyberdrop_dl.constants import BlockedDomains
from cyberdrop_dl.crawlers import ALLOW_NO_EXT, create_crawlers
from cyberdrop_dl.exceptions import JDownloaderError, NoExtensionError
from cyberdrop_dl.logs import log_spacer
+from cyberdrop_dl.models.validators import bytesize_to_str
from cyberdrop_dl.progress.scraping import ScrapingUI
from cyberdrop_dl.scrape_source import (
RetryQuery,
@@ -180,9 +179,7 @@ class ScrapeMapper:
if config.sort.enabled:
config.sort.output_folder.mkdir(parents=True, exist_ok=True)
- logger.debug(
- "Using %s as chunk size", ByteSize(self.manager.download_client.chunk_size).human_readable(decimal=True)
- )
+ logger.debug("Using %s as chunk size", bytesize_to_str(self.manager.download_client.chunk_size))
await self.manager.http_client.load_cookie_files(await self.manager.get_cookie_files())
self.tui.mode = self.manager.config.ui.mode
## IMPORTANT: Order of each context matters!
diff --git a/cyberdrop_dl/storage/_psutil.py b/cyberdrop_dl/storage/_psutil.py
index 3274d52ad..4616f8f9b 100644
--- a/cyberdrop_dl/storage/_psutil.py
+++ b/cyberdrop_dl/storage/_psutil.py
@@ -11,7 +11,8 @@ from pathlib import Path
from typing import TYPE_CHECKING, Final
import psutil
-from pydantic import ByteSize
+
+from cyberdrop_dl.models.validators import bytesize_to_str
if TYPE_CHECKING:
from collections.abc import Generator
@@ -118,7 +119,7 @@ def _partition_stats() -> Generator[dict[str, str]]:
free_space = _free_space.get(partition.mountpoint)
if free_space is not None:
stats = partition.__json__()
- stats["free_space"] = ByteSize(free_space).human_readable(decimal=True)
+ stats["free_space"] = bytesize_to_str(free_space)
yield stats
diff --git a/docs/reference/config/general.md b/docs/reference/config/general.md
index 10f57b505..974177062 100644
--- a/docs/reference/config/general.md
+++ b/docs/reference/config/general.md
@@ -83,12 +83,12 @@ max_folder_name_length: 60
| Type | Default | Restrictions |
| ---------- | ------- | ------------ |
-| `ByteSize` | `5GB` | `>=512MB` |
+| `ByteSize` | `5GiB` | `>=512MiB` |
This is the minimum amount of free space require to start new downloads.
```yaml
-min_free_space: 5.0GB
+min_free_space: 5.0GiB
```
{% hint style="info" %}