Skip to content

Conversation

@ExcitedHumvee
Copy link

Description

Implements tilde (~) expansion for home directory paths in qBittorrent configurations, addressing issue #17583.

This allows users to specify paths like ~/Downloads instead of hard-coded absolute paths like /home/username/Downloads, making configuration files portable across users and systems.

Changes Made

  • Core Implementation:

    • Added Utils::Fs::expandTilde() function to handle ~ and ~/path expansion
    • Integrated tilde expansion in SessionImpl for save/download path handling
    • Added tilde expansion support for category save paths
    • Applied expansion both during settings loading and when paths are set
  • Testing:

    • Added comprehensive test suite testtildeexpansion.cpp
    • Tests cover all supported patterns: ~, ~/path, absolute paths, relative paths, empty paths
    • All 17 tests pass (including 8 tilde expansion tests)

Features

  • Supports ~ (home directory) and ~/path (home + subpath) patterns
  • Maintains backward compatibility with existing absolute/relative paths
  • Cross-platform support for Windows, macOS, and Linux
  • Security conscious: ~username patterns explicitly not supported
  • Automatic expansion during config loading and path setting

Use Cases Addressed

  • Portable configurations: Users can share config files without user-specific paths
  • Easier backup/restore: No need to edit paths when restoring settings
  • Intuitive usage: Users can type ~/Downloads instead of /home/username/Downloads
  • Cross-system compatibility: Same config works across different user accounts

Testing

# Run the specific test
make testtildeexpansion && ./test/testtildeexpansion

# Run full test suite  
make check

Enables using ~ and ~/path in configurations instead of hard-coded
absolute paths, making settings portable across users.

- Add Utils::Fs::expandTilde() function
- Integrate tilde expansion in session path handling
- Support category path tilde expansion
- Add comprehensive test coverage
@Chocobo1 Chocobo1 added the Core label Aug 15, 2025
- Rename testtildeexpansion.cpp to testutilsfs.cpp as requested
- Follow qBittorrent coding style with proper copyright header
- Add missing Q_DISABLE_COPY_MOVE directive and const methods
- Update CMakeLists.txt to reference correct test filename
- All 17 tests pass including tilde expansion functionality
@glassez glassez changed the title feat: Add tilde (~) expansion support for home directory paths Add tilde (~) expansion support for home directory paths Aug 17, 2025
@github-actions
Copy link

This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity.

@github-actions github-actions bot added the Stale label Oct 17, 2025
@ExcitedHumvee
Copy link
Author

@Chocobo1 , I've addressed the feedback. Could you please take another look when you have a moment?

@github-actions github-actions bot removed the Stale label Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants