Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

XDG save_config_path raises FileExistsError #3044

Closed
@krisgesling

Description

Describe the bug
The pyxdg save_config_path ensures that a directory exists before using it. This is done using os.path:
https://github.com/takluyver/pyxdg/blob/master/xdg/BaseDirectory.py#L57-L58

Based on the Traceback below I'm wondering if we have items starting in separate threads, that are both checking/creating the XDG paths.

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/opt/mycroft/mycroft/__init__.py", line 17, in <module>
    from mycroft.api import Api
  File "/opt/mycroft/mycroft/api/__init__.py", line 23, in <module>
    from mycroft.configuration import Configuration
  File "/opt/mycroft/mycroft/configuration/__init__.py", line 15, in <module>
    from .config import Configuration, LocalConf, RemoteConf
  File "/opt/mycroft/mycroft/configuration/config.py", line 28, in <module>
    from .locations import DEFAULT_CONFIG, USER_CONFIG, OLD_USER_CONFIG
  File "/opt/mycroft/mycroft/configuration/locations.py", line 26, in <module>
    USER_CONFIG = join(xdg.BaseDirectory.save_config_path('mycroft'),
  File "/opt/mycroft/.venv/lib/python3.8/site-packages/xdg/BaseDirectory.py", line 58, in save_config_path
    os.makedirs(path, 0o700)
  File "/usr/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/home/mycroft/.config/mycroft'

I haven't yet found other projects hitting the same issue.

Expected behavior
Create the directory if it doesn't exist, otherwise just use it.

Environment (please complete the following information):

  • Device type: Mark 2
  • OS: Mark 2 build dated 2021-11-25 15:34
  • Mycroft-core version: 21.2.1
  • pyxdg v0.26

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions