Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: change the working-dir searchpath when using '-c' #8367

Merged
merged 2 commits into from Dec 13, 2020

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Dec 8, 2020

Basically, with '-c' you now create a sandbox. It will still use
your personal-dir and global-dir to find files you installed there,
but all new files are stored with a base folder identical to the
folder the configuration is in.

This is a bit of an old bug, that we many have tried to solve in
various of different ways. The code has grown sufficiently complex
that it is hard to see what consequences of actions are. This is
in my opinion the most harmless solution, while increasing the
usefulness of the '-c' flag.

In essence, the problem was that empty folders were always created
in the directory where the configuration was, but as that directory
wasn't added to any searchpath, files weren't stored there, unless
by accident it was a folder already on the searchpath. For example,
if you do './openttd -c local.cfg', it did work as expected. But
in the more generic variant, it did not.

With this patch, you can run './openttd -c /new/folder/local.cfg',
and it will create and prepare that folder to receive new files.

'content_download' is also stored in the directory the
configuration is in; this was already the case. Important to
note that there is only one search-path for 'content_download'.
In other words, when using '-c', it will not look in '~/.openttd'
inside the 'content_download' folder.

@TrueBrain TrueBrain force-pushed the fix_personal_hell branch 2 times, most recently from 6b08762 to 5331d5a Compare December 8, 2020 22:48
@TrueBrain TrueBrain changed the title Fix: create folders in personal-dir on startup when -c is given Codechange: to create or not to create a folder, that is the question Dec 8, 2020
@TrueBrain TrueBrain changed the title Codechange: to create or not to create a folder, that is the question Fix: change the working-dir searchpath when using '-c' Dec 8, 2020
@TrueBrain TrueBrain force-pushed the fix_personal_hell branch 3 times, most recently from e6b9420 to 85c7a34 Compare December 8, 2020 23:17
michicc
michicc previously approved these changes Dec 13, 2020
Copy link
Member

@michicc michicc left a comment

Choose a reason for hiding this comment

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

The code itself looks fine. It might affect people who run multiple servers on one machine, but I'm not really qualified to say whether this has any effect on them.

This was just weird. With XDG _personal_dir was created already,
but later on it was checked if it was different from config_dir,
and the creation was skipped. All this checking and validation
makes my head spin .. let's make it a bit more simple.
Basically, with '-c' you now create a sandbox. It will still use
your personal-dir and global-dir to find files you installed there,
but all new files are stored with a base folder identical to the
folder the configuration is in.

This is a bit of an old bug, that we many have tried to solve in
various of different ways. The code has grown sufficiently complex
that it is hard to see what consequences of actions are. This is
in my opinion the most harmless solution, while increasing the
usefulness of the '-c' flag.

In essence, the problem was that empty folders were always created
in the directory where the configuration was, but as that directory
wasn't added to any searchpath, files weren't stored there, unless
by accident it was a folder already on the searchpath. For example,
if you do './openttd -c local.cfg', it did work as expected. But
in the more generic variant, it did not.

With this patch, you can run './openttd -c /new/folder/local.cfg',
and it will create and prepare that folder to receive new files.

'content_download' is also stored in the directory the
configuration is in; this was already the case. Important to
note that there is only one search-path for 'content_download'.
In other words, when using '-c', it will not look in '~/.openttd'
inside the 'content_download' folder.
@TrueBrain TrueBrain merged commit da7c74b into OpenTTD:master Dec 13, 2020
@TrueBrain TrueBrain deleted the fix_personal_hell branch December 13, 2020 15:41
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.

None yet

3 participants