Skip to content

Normalize firmware DB paths to POSIX format for cross-platform compatibility#92

Merged
Josverl merged 2 commits into
mainfrom
copilot/fix-windows-linux-database-issue
May 20, 2026
Merged

Normalize firmware DB paths to POSIX format for cross-platform compatibility#92
Josverl merged 2 commits into
mainfrom
copilot/fix-windows-linux-database-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

When the same firmware folder is accessed from both Windows and Linux/WSL2, Path.relative_to() produces OS-native separators (\ vs /). This causes clean_downloaded_firmwares() to fail matching DB records against disk files, incorrectly deleting valid records.

Changes

  • mpflash/download/from_web.py: Use .as_posix() instead of str() when storing the relative path after download
  • mpflash/downloaded.py: Use .as_posix() when building the on-disk file set for comparison with DB records

Both db/loader.py and custom/naming.py already used .as_posix() — these two call sites were the only ones missing normalization.

# Before (OS-dependent separators)
board.firmware_file = str(filename.relative_to(firmware_folder))

# After (always forward slashes)
board.firmware_file = filename.relative_to(firmware_folder).as_posix()

Tests

Added two tests validating that POSIX paths are used consistently for DB storage and disk-vs-DB comparison.

Copilot AI linked an issue May 19, 2026 that may be closed by this pull request
…ompatibility

Use .as_posix() instead of str() when storing and comparing relative
firmware paths in the database. This prevents path separator mismatches
(backslash vs forward slash) when the same firmware folder is accessed
from both Windows and Linux/WSL2.

Fixes: Windows/Linux conflicts in mpflash database

Agent-Logs-Url: https://github.com/Josverl/mpflash/sessions/b370abd5-407c-4f64-9aa2-03ffefb02d91

Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Windows/Linux conflicts in mpflash database Normalize firmware DB paths to POSIX format for cross-platform compatibility May 19, 2026
Copilot AI requested a review from Josverl May 19, 2026 23:20
@Josverl Josverl marked this pull request as ready for review May 20, 2026 00:12
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.58%. Comparing base (c5bed8f) to head (0977cb2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   75.55%   75.58%   +0.03%     
==========================================
  Files          54       54              
  Lines        3031     3031              
  Branches      488      488              
==========================================
+ Hits         2290     2291       +1     
  Misses        621      621              
+ Partials      120      119       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Josverl Josverl merged commit 62eb861 into main May 20, 2026
33 checks passed
@Josverl Josverl deleted the copilot/fix-windows-linux-database-issue branch May 20, 2026 00:43
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.

Windows/Linux conflicts in mpflash database ?

2 participants