Skip to content

Respect local environment configuration for app file storage - #4606

Open
100jinwoo001 wants to merge 17 commits into
beeware:mainfrom
100jinwoo001:fix-2867-local-storage
Open

Respect local environment configuration for app file storage#4606
100jinwoo001 wants to merge 17 commits into
beeware:mainfrom
100jinwoo001:fix-2867-local-storage

Conversation

@100jinwoo001

@100jinwoo001 100jinwoo001 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR updates the app file storage logic to respect the local environment configuration instead of always using the default platform-specific paths.

Fixes #2867.

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: ChatGPT

@100jinwoo001
100jinwoo001 force-pushed the fix-2867-local-storage branch 3 times, most recently from 01ba65b to 2e8bbfb Compare August 2, 2026 16:15
…#2867)

Signed-off-by: 100jinwoo001 <rahul.patel09@infosys.com>
@100jinwoo001
100jinwoo001 force-pushed the fix-2867-local-storage branch from 2e8bbfb to f26bc36 Compare August 2, 2026 16:52
@freakboy3742

Copy link
Copy Markdown
Member

This PR is marked draft, but it's passing CI - was it your intention to have this reviewed?

As an aside - there's no need to include "testing" details when the details are "I ran the test suite". A passing test suite is not negotiable, so it's not notable.

@100jinwoo001
100jinwoo001 marked this pull request as ready for review August 6, 2026 06:02
@100jinwoo001
100jinwoo001 marked this pull request as draft August 6, 2026 10:08
@100jinwoo001
100jinwoo001 marked this pull request as ready for review August 11, 2026 13:43

@shinzoxD shinzoxD left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for carrying this across GTK, Qt, Textual, and WinForms. I found two correctness/coverage gaps that need addressing before this satisfies Toga's contribution rules:

  1. The XDG variables are accepted without checking that they are absolute. The XDG Base Directory specification requires relative values to be treated as invalid and ignored (https://specifications.freedesktop.org/basedir/latest/#basics). With XDG_CONFIG_HOME=relative-config, for example, this head returns relative-config/; toga.Paths.config then creates that directory relative to the process working directory, despite Toga documenting app paths as absolute. Please validate all four XDG values with Path.is_absolute() and fall back to their defaults when unset, empty, or relative; include the invalid-relative case in the tests.

  2. The AppProbe changes adapt expected values to the same environment, but CI does not set non-default XDG_*_HOME or LOCALAPPDATA values. On the current runners these assertions still exercise only the old default paths, so the testbed would pass even if the production methods continued ignoring the variables. Please add a regression path that sets non-default absolute values before app.paths is cached and verifies config/data/cache/logs on Linux and Windows.

Because this is a user-visible behavioral change, the repository constitution also requires updating the Paths documentation (docs/en/reference/api/data-representation/paths.md or the file-management topic) to describe these environment overrides. The change note itself is present and clear.

@100jinwoo001
100jinwoo001 marked this pull request as draft August 11, 2026 20:20
@100jinwoo001
100jinwoo001 force-pushed the fix-2867-local-storage branch 3 times, most recently from 3e83636 to 0f23bd8 Compare August 11, 2026 20:38
@100jinwoo001
100jinwoo001 force-pushed the fix-2867-local-storage branch from 0f23bd8 to 2f71930 Compare August 11, 2026 21:19
@freakboy3742

Copy link
Copy Markdown
Member

Closing as there's been no response from the PR author to a direct question in over a week.

@shinzoxD Please familiarise yourself with our project AI policy. We do not want random drive-by "reviews" from automated agents.

@100jinwoo001

Copy link
Copy Markdown
Contributor Author

Hi @freakboy3742 , I had provided the PR code for the Black Duck scan and was waiting for the green signal before raising the actual PR, so that’s why there was a delay from my side.

@freakboy3742 freakboy3742 reopened this Aug 12, 2026
@freakboy3742

Copy link
Copy Markdown
Member

Hi @freakboy3742 , I had provided the PR code for the Black Duck scan and was waiting for the green signal before raising the actual PR, so that’s why there was a delay from my side.

No worries - for future reference, if you're asked a question, it's generally a good idea to respond, even if the answer is "not yet, I'm waiting on something".

I'm also I'm not sure what a "Black Duck" scan is - it's not something from our contribution guide. Your PR is, however, failing pre-commit checks - something our contribution guide does cover.

Lastly - please don't force push repositories. When you force push, we lose context of any historical reviews. In this case, there haven't been any reviews yet - but it's a good habit to get into. We don't care about a "messy" commit history, as we collapse commits on merge.

@100jinwoo001
100jinwoo001 marked this pull request as ready for review August 12, 2026 08:11
@100jinwoo001
100jinwoo001 marked this pull request as draft August 12, 2026 08:11
@100jinwoo001
100jinwoo001 marked this pull request as ready for review August 12, 2026 09:39

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR; this mostly looks good, but a couple of simplifications, and some modifications that seem to be unrelated have been flagged inline.

Comment thread core/tests/test_paths.py
)
def test_cant_reassign(app, path_name):
"""App path attributes are read-only."""
# Theoretically, this could leak out of this test... but only if it fails!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please don't remove comments that are still accurate, correct, and unrelated to the changes that you're making.

Comment thread qt/src/toga_qt/widgets/selection.py Outdated
self.native.setSizePolicy(
QSizePolicy.Policy.Expanding,
QSizePolicy.Policy.Fixed,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does this have to do with paths?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again - what do these changes have to do with paths?

Comment thread textual/src/toga_textual/paths.py Outdated
Comment thread textual/tests_backend/app.py Outdated
Comment on lines +41 to +44
local_app_data = os.environ.get("LOCALAPPDATA")
base_dir = (
Path(local_app_data) if local_app_data else (Path.home() / "AppData/Local")
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again, os.environ.get() has a fallback mode.

Comment thread winforms/src/toga_winforms/paths.py Outdated
local_app_data = os.environ.get("LOCALAPPDATA")
base_dir = (
Path(local_app_data) if local_app_data else (Path.home() / "AppData/Local")
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same again - fallback mode can be used to simplify things.

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.

Local environment configuration is not respected for app file storage

3 participants