Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fix skip by download size marking as previous download
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Jan 28, 2024
1 parent b324a69 commit 538851e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.54"
__version__ = "5.1.55"
14 changes: 10 additions & 4 deletions cyberdrop_dl/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,19 @@ async def set_additional_headers(self) -> None:
self._additional_headers["Authorization"] = await self.manager.download_manager.basic_auth("Cyberdrop-DL", self.manager.config_manager.authentication_data['PixelDrain']['pixeldrain_api_key'])

async def get_final_file_info(self, complete_file: Path, partial_file: Path,
media_item: MediaItem) -> tuple[Path, Path, bool]:
media_item: MediaItem) -> tuple[Path, Path, bool, bool]:
"""Complicated checker for if a file already exists, and was already downloaded"""
expected_size = media_item.filesize if isinstance(media_item.filesize, int) else None
proceed = True
skip = False
while True:
if not expected_size:
media_item.filesize = await self.client.get_filesize(media_item)
file_size_check = await self.check_filesize_limits(media_item)
if not file_size_check:
proceed = False
return complete_file, partial_file, proceed
skip = True
return complete_file, partial_file, proceed, skip

if not complete_file.exists() and not partial_file.exists():
break
Expand Down Expand Up @@ -266,7 +268,7 @@ async def get_final_file_info(self, complete_file: Path, partial_file: Path,
partial_file = complete_file.with_suffix(complete_file.suffix + '.part')

media_item.download_filename = complete_file.name
return complete_file, partial_file, proceed
return complete_file, partial_file, proceed, skip

async def iterate_filename(self, complete_file: Path, media_item: MediaItem) -> Tuple[Path, Path]:
"""Iterates the filename until it is unique"""
Expand Down Expand Up @@ -317,9 +319,13 @@ async def download(self, media_item: MediaItem) -> None:
complete_file = download_dir / media_item.filename
partial_file = complete_file.with_suffix(complete_file.suffix + '.part')

complete_file, partial_file, proceed = await self.get_final_file_info(complete_file, partial_file, media_item)
complete_file, partial_file, proceed, skip_by_config = await self.get_final_file_info(complete_file, partial_file, media_item)
await self.mark_incomplete(media_item)

if skip_by_config:
await self.manager.progress_manager.download_progress.add_skipped()
return

if not proceed:
await log(f"Skipping {media_item.url} as it has already been downloaded", 10)
await self.manager.progress_manager.download_progress.add_previously_completed(False)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.1.54"
version = "5.1.55"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 538851e

Please sign in to comment.