You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unix.user_documents_dir ignores ensure_exists=True for XDG_DOCUMENTS_DIR #558
Unix(ensure_exists=True).user_documents_path returns the directory configured by XDG_DOCUMENTS_DIR without creating it or its parents. The same instance creates user_data_path as expected. Unix.user_documents_dir returns _get_user_media_dir(...) directly, bypassing _optionally_create_directory.
Reproduced against main at 6d287024230ad1c040e537cfd97ef8df6fd6b229, using an editable install:
importosfrompathlibimportPathfromtempfileimportTemporaryDirectoryfromplatformdirs.uniximportUnixwithTemporaryDirectory() asroot:
base=Path(root)
os.environ["XDG_DATA_HOME"] =str(base/"data")
os.environ["XDG_DOCUMENTS_DIR"] =str(base/"parent"/"Documents")
dirs=Unix(ensure_exists=True)
data=dirs.user_data_pathdocuments=dirs.user_documents_pathprint(f"user_data_path: exists={data.is_dir()}")
print(f"user_documents_path: exists={documents.is_dir()}")
assertdocuments.is_dir(), "ensure_exists did not create the documents directory"
Actual output:
user_data_path: exists=True
user_documents_path: exists=False
AssertionError: ensure_exists did not create the documents directory
Expected: both directories exist after property access. The ensure_exists parameter documentation says: “When True, the directory is created (including parents) when the property is accessed.” The implicated return is in Unix.user_documents_dir.
#550 explicitly left creation of media directories as a separate question; this is a minimal example of that remaining behavior. This report was prepared with AI assistance and checked against the source and the reproduction above.
Activity
🐛 fix(dirs): only create configured media dirs