Fix .vorta-init.json import for Flatpak environments#2465
Fix .vorta-init.json import for Flatpak environments#2465Nishani-B wants to merge 3 commits intoborgbase:masterfrom
Conversation
m3nu
left a comment
There was a problem hiding this comment.
Thanks for working on this. The issue is real, but I don't think this PR correctly addresses it.
Core issue: os.path.expanduser("~") and Path.home() are identical
Path.home() is implemented by calling os.path.expanduser("~"). Both check the HOME env var first. In a Flatpak sandbox where HOME is overridden to the sandboxed directory, both return the same sandboxed path. The "fallback" added here is always a no-op.
To actually bypass a Flatpak HOME override, you'd need to query the password database directly:
import pwd
real_home = Path(pwd.getpwuid(os.getuid()).pw_dir)Other issues
-
Broken docstring — The docstring was moved below the first executable line (
bootstrap_file = bootstrap_file or ...), turning it from a method docstring into a dead string expression. -
Unrelated indentation change — The closing paren of
notifier.deliver()was re-indented without reason. -
Redundant
.is_file()check — After the for-loop already confirmed the file exists and setbootstrap_file, the originalif bootstrap_file.is_file():check runs again redundantly. -
No tests for a path-resolution change that's difficult to verify manually across environments.
|
I've addressed all the review feedback in the latest commit Here's a summary of what was fixed:
|
Fixes #2464
Description
Vorta looks for
.vorta-init.jsonusingPath.home(), which in a Flatpaksandbox resolves to the sandboxed directory because Flatpak overrides the
HOMEenvironment variable. BothPath.home()andos.path.expanduser("~")read
HOME, so the previous fallback was a no-op.Solution
Use
pwd.getpwuid(os.getuid()).pw_dirto query the password database directly,bypassing any
HOMEoverride. This correctly resolves the real home directoryeven inside a Flatpak sandbox.
Changes addressing review feedback
os.path.expanduser("~")withpwd.getpwuid(os.getuid()).pw_dirto actually bypass the Flatpak HOME override (previous fallback was a no-op)
bootstrap_profile()(was placed after an executable line, making it a dead string expression)
notifier.deliver().is_file()check after the for-looptests/unit/test_bootstrap_profile.py— 11 tests coveringFlatpak HOME bypass, path resolution, default profile creation,
file lifecycle, and docstring placement
Types of changes
Checklist