OpenArena / engine

OpenArena modifications to the ioquake3 engine
http://openarena.ws
GNU General Public License v2.0
212 stars 50 forks source link

Homepath on *nix should fllow the XDG standard? #30

Closed sago007 closed 7 years ago

sago007 commented 7 years ago

I admit that it is a little late to move the home folder to a more standard location but I think it should be done. This is why there is a "?" in the title.

Currently "$HOME/.openarena" is used. This should be "$XDG_DATA_HOME/openarena" Where XDG_DATA_HOME should default to "$HOME/.local/share" if not defined.

A possible solution could be to check for presence of "$XDG_DATA_HOME/openarena" if it exists and then try "$HOME/.openarena" if it does not exist: Create "$XDG_DATA_HOME/openarena" and create a symbolic link in "$HOME/.openarena" to it. After a couple of years then all the documentation has been updated we stop creating the symbolic link.

A way to make the transfer easier is to move the .openarena folder to "$XDG_DATA_HOME/openarena" and create the symbolic link in case .openarena exists and the other does not. It can be a bit risky. We need to test the case where .local/share is mounted on a different disk than .openarena.

Furthermore the engine currently assumes that $HOME is defined. This is normally the case but it should continue to look for passwd in case it is not. I don't think it is worth looking into. People would have complained.

sago007 commented 7 years ago

Of course if fs_homepath is given it should just accept it as is.

The-Gig commented 7 years ago

I do not know, and I can't help with tests under *nix. I can only say that if one really needs to change a such thing, probably the passage from 0.x to 3.x may be the best moment.

ldrone commented 7 years ago

What about an option to check if $HOME/.openarena and $XDG_DATA_HOME exist, and if true move the files to $XDG_DATA_HOME/openarena?

sago007 commented 7 years ago

What about an option to check if $HOME/.openarena and $XDG_DATA_HOME exist, and if true move the files to $XDG_DATA_HOME/openarena?

That was my plan. It just needs extremely good testing because there is a rare problem with $XDG_DATA_HOME being mounted separately causing a trivial move to fail. It is rare but I have observed it on an actual system. If the data needs to be moved across a mount point you'll need to do copy+delete and that is a lot more dangerous. And even that can fail if .openarena itself is a mount.

Of course it can be done in the trivial case and it is very simple for the trivial case. But in other cases I would properly go for a symlink solution: If HOME is an invalid symlink. Unlink it. If XDG_HOME is an invalid symlink. Unlink it. If neither HOME or XDG_HOME exists: Create XDG_HOME as a directory. If HOME exist and XDG_HOME exist: Do nothing. Just use XDG_HOME If HOME exist and XDG_HOME does not: Try to move. If HOME still exist and XDG_HOME does not: Create a symlink from XDG_HOME to HOME. If XDG_HOME exist and HOME does not: Create symlink from HOME to XDG_HOME. Use XDG_HOME.

Multiple rules can be hit but the end result should be that both HOME and XDG_HOME exists and points to each other. The user can create both directories as actual directories and in that case they will live on independently.

sago007 commented 7 years ago

I have a branch containing an implementation of this (https://github.com/OpenArena/engine/tree/xdg_home).

It works close to how it is described. However: "$XDG_DATA_HOME/OpenArena" is used instead of "$XDG_DATA_HOME/openarena".

This makes it closer to the MacOS and Windows structure. com_homepath only relates to the "OpenArena" part. There is no way of changing the old path.

I have tested: .openarena exist OpenArena does not. It is moved and .openarena is added as a symlink to OpenArena. Ok .openarena is missing but OpenArena exist. Symlink .openarena is created. Ok .openarena is an invalid symlink but OpenArena exist. Symlink .openarena is corrected. Ok Neither folder exists and .local/share does not exist either. OpenArena is created with full path and .openarena is created as a symlink. Ok (I don't know how the folders are created recursively but it works). (Edit: The symlink was not created until the second run. It would be better if it was created in the first)

What needs to be tested: I need some test cases where .openarena cannot be moved (making it a mount). One where .local/share does not exist. To ensure that the symlink can be created.

sago007 commented 7 years ago

The cases where .openarena cannot be moved has now been tested and fixed. If OpenArena does not exist it is now created as a symlink to it.

Also: Neither folder exists and .local/share does not exist either. OpenArena is created with full path and .openarena is created as a symlink. Ok (It now works on first run)

sago007 commented 7 years ago

Merged in with #31