Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Enhancement: Use XDG Directory Specification by default on Linux #2035

Merged
merged 6 commits into from
Feb 27, 2025
Merged

Conversation

qnixsynapse
Copy link
Contributor

@qnixsynapse qnixsynapse commented Feb 26, 2025

Describe Your Changes

This PR updates file path handling on Linux to follow the XDG Base Directory Specification, ensuring better organization and adherence to standard Linux conventions.

Changes

  • Introduced GetXDGDirectoryPath() to retrieve XDG-compliant paths with proper fallbacks.
  • Updated:
    • GetConfigurationPath(), GetDefaultConfig(),
      CreateConfigIfNotExist(),
      GetCortexDataPath(), and GetCortexLogPath() to use XDG_CONFIG_HOME and XDG_DATA_HOME instead of defaulting to $HOME on Linux.
  • Ensured missing directories are created when necessary.

Impact

  • Linux Users: Configuration, data, and logs now follow XDG standards.
  • Improved Maintainability: Cleaner and safer path handling.

Fixes Issues

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

Tested locally by running cortex, downloading a model from cortexso running it as cli.
This might cause some breaking changes. Need to test it more before merging to ensure no regressions.

@qnixsynapse qnixsynapse marked this pull request as draft February 26, 2025 15:53
@qnixsynapse qnixsynapse self-assigned this Feb 26, 2025
@qnixsynapse qnixsynapse marked this pull request as ready for review February 27, 2025 01:59
@qnixsynapse
Copy link
Contributor Author

qnixsynapse commented Feb 27, 2025

Why the log folder is hard coded to home/<build_variant_folder_name>/logs in e2e?

root = Path.home()
>       assert (
            os.path.exists(root / "cortexcpp" / "logs")
            or os.path.exists(root / "cortexcpp-beta" / "logs")
            or os.path.exists(root / "cortexcpp-nightly" / "logs")
        )

Edit: Fixed the failing test.

@qnixsynapse qnixsynapse merged commit 0151617 into dev Feb 27, 2025
7 of 8 checks passed
@qnixsynapse qnixsynapse deleted the xds branch February 27, 2025 06:52
vansangpfiev pushed a commit that referenced this pull request Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Follow XDG directory specification on Linux by default
2 participants