Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Restore missing first progress line #58

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions podcast_archiver/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __call__(self) -> DownloadResult:
)
response.raise_for_status()
total_size = int(response.headers.get("content-length", "0"))
self.update_progress(total=total_size, visible=True)
self.update_progress(total=total_size)

self.target.parent.mkdir(parents=True, exist_ok=True)
if not self.receive_data(self.tempfile, response):
Expand All @@ -88,7 +88,7 @@ def tempfile(self) -> Path:
return self.target.with_suffix(self.target.suffix + ".part")

def init_progress(self) -> None:
if not self._progress:
if self._progress is None:
return

self._task_id = self._progress.add_task(
Expand All @@ -99,8 +99,9 @@ def init_progress(self) -> None:
)

def update_progress(self, visible: bool = True, **kwargs: Any) -> None:
if not self._progress or not self._task_id:
if self._task_id is None:
return
assert self._progress
self._progress.update(self._task_id, visible=visible, **kwargs)

def preflight_check(self) -> DownloadResult | None:
Expand Down
Loading