Skip to content

Linux: follow XDG guidelines#20

Merged
illwieckz merged 3 commits intoDaemonEngine:for-0.51.0from
illwieckz:xdgpath
Jul 10, 2017
Merged

Linux: follow XDG guidelines#20
illwieckz merged 3 commits intoDaemonEngine:for-0.51.0from
illwieckz:xdgpath

Conversation

@illwieckz
Copy link
Copy Markdown
Member

@illwieckz
Copy link
Copy Markdown
Member Author

There is just a minor issue, the early warning is not colored:

^3Warn: [FS] Renaming legacy home path /home/illwieckz/.unvanquished to /home/illwieckz/.local/share/unvanquished

return std::string(home) + "/." PRODUCT_NAME_LOWER;
struct stat stl, stx;

std::string legacyHomePath = std::string(home) + "/." PRODUCT_NAME_LOWER;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use FS::Path::Build() to build paths.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@illwieckz
Copy link
Copy Markdown
Member Author

Note that if someone symlink ~/.unvanquished to ~/.local/share/unvanquished (or the opposite), this one can load both current game and for-0.51.0 game. On 0.51.0 release, player that only have ~/.unvanquished will get his ~/.unvanquished renamed to ~/.local/share/unvanquished.

- use ~/.local/share/unvanquished instead of ~/.unvanquished
- move legacy path if exists
- fix Unvanquished/Unvanquished#730
Copy link
Copy Markdown
Contributor

@DolceTriade DolceTriade left a comment

Choose a reason for hiding this comment

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

Minor nit, but otherwise seems fine.

@illwieckz
Copy link
Copy Markdown
Member Author

I modified my code to handle the symlink use case (if ~/.unvanquished was a symlink), in this case, it create a new symlink in ~/.local/share/unvanquished but do not remove the first one (the safest choice), displaying a warning.

int fd = open(xdgDataHome.c_str(), O_DIRECTORY);

if (fd == -1) {
Sys::Error("Could not open XDG data directory %s", xdgDataHome);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

include strerror(errno) at the end so we know why it failed.

ret = symlinkat(legacyHomePath.c_str(), fd, xdgHomePath.c_str());

if (ret == -1) {
Sys::Error("Could not create symlink %s", xdgHomePath);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

strerror(errno)


if (fd == -1) {
Sys::Error("Could not open XDG data directory %s", xdgDataHome);
Sys::Error("Could not open XDG data directory %s: %s", xdgDataHome, strerror(errno));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@DolceTriade like that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes

@illwieckz
Copy link
Copy Markdown
Member Author

illwieckz commented Jul 10, 2017

Do you think it's OK to merge that change in for-0.51.0 branch?

Not doing this would prevent @DefaultUser to rebase his #16 work over this code. I don't know how much this change things for him and how much he needs to rebase on this code.

I guess it's OK if we say people wanting to try out for-0.51.0 are invited to symlink ~/.unvanquished and ~/.local/share/unvanquished (or creating a brand new ~/.local/share/unvanquished if they want to test a clean start). Dæmon will not change anything if both exists, so developers can already work with the new path while keeping the old one to play some games using the last release.

@DolceTriade
Copy link
Copy Markdown
Contributor

yes its fine

@illwieckz illwieckz merged commit 810fa00 into DaemonEngine:for-0.51.0 Jul 10, 2017
@DefaultUser
Copy link
Copy Markdown
Contributor

@illwieckz updating #16 should be easy since all that needs to be changed in your new code are the two instances of PRODUCT_NAME_LOWER (change to Gameinfo::getInstance().name())

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.

3 participants