Skip to content

Conversation

@amilcarlucas
Copy link
Collaborator

Close self.fh in __terminate_session() before clearing it so the OS file descriptor is released. This prevents PermissionError when saving complete.param on subsequent downloads. Log any close errors for diagnostics.

Closes #1151

Copilot AI review requested due to automatic review settings December 23, 2025 18:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a PermissionError that occurred when saving complete.param on subsequent downloads by ensuring the file handle is properly closed before clearing its reference in the __terminate_session() method.

Key Changes:

  • Added proper file handle cleanup in __terminate_session() to close self.fh before setting it to None
  • Added error handling with logging for any exceptions during file close operations
  • Used try-except-finally pattern to ensure self.fh is always set to None even if close fails

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
10740 9748 91% 89% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 28ca460 by action🐍

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

Test Results

    3 files      3 suites   31m 41s ⏱️
2 739 tests 2 734 ✅  5 💤 0 ❌
8 217 runs  8 202 ✅ 15 💤 0 ❌

Results for commit 28ca460.

♻️ This comment has been updated with latest results.

Close self.fh in __terminate_session() before clearing it so the OS file descriptor is released.
This prevents PermissionError when saving complete.param on subsequent downloads.
Log any close errors for diagnostics.

Closes #1151
@amilcarlucas amilcarlucas merged commit d159001 into master Dec 23, 2025
31 checks passed
@amilcarlucas amilcarlucas deleted the fix_1151 branch December 23, 2025 19:51
amilcarlucas added a commit that referenced this pull request Dec 24, 2025
…or installer downloads

- Make vehicles/templates backup optional (default off)
- Add _compute_sha256() helper and verify downloaded installer when expected SHA256 provided
- Use non-vehicles backup by default in update flows

Ref: update resilience and security for software update process
amilcarlucas added a commit that referenced this pull request Dec 24, 2025
- Add get_expected_sha256_from_release() to parse checksum assets or release body
- Pass expected SHA256 to download_and_install_on_windows in update manager
- Improve installer verification before execution
amilcarlucas added a commit that referenced this pull request Dec 24, 2025
- Add download_and_install_wheel_asset() helper
- Prefer release wheel assets for non-Windows installs and verify SHA256
- Fallback to pip install when no wheel asset is available
amilcarlucas added a commit that referenced this pull request Dec 27, 2025
- Add retries, exponential backoff and jitter
- Support HTTP Range resume when allowed
- Preserve progress callback behavior
amilcarlucas added a commit that referenced this pull request Dec 27, 2025
…b.suppress, and consolidate returns

- Split download logic into helper to satisfy PLR0915
- Added `expected_sha256` docstring entry for `download_and_install_on_windows`
- Replace try/except pass with `contextlib.suppress(OSError)`
- Mark pip install subprocess call with `# noqa: S603`
- Consolidate return paths in UpdateManager._perform_download to satisfy PLR0911
amilcarlucas added a commit that referenced this pull request Dec 27, 2025
…0915)

- Extract small helpers: _build_proxies, _existing_size_and_headers, _parse_total_size, _write_response
- Keep external API of download_file_from_url unchanged
amilcarlucas added a commit that referenced this pull request Dec 28, 2025
…y and annotation linters

- Move helper functions to module level with proper type annotations
- Implement clean retry loop using helpers
- Keep external API unchanged
amilcarlucas added a commit that referenced this pull request Dec 28, 2025
…mpt helper

- Extracted `_attempt_download_once` with type annotations
- Simplified `download_file_from_url` to reduce cyclomatic complexity
- Kept behavior and tests passing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permission denied on different FC connection

2 participants