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

Installing 5.1.x after 5.2.x will no longer override config/data locations #1708

Conversation

hgohel
Copy link
Member

@hgohel hgohel commented Apr 18, 2024

Fix #13261

In an existing 5.2.x installation with XDG directory layout for data/config/cache, installing 5.1.x later would create a second config folder in the legacy layout, overriding the existing config.

This change makes it so that an existing configuration for 5.2.x will be given preference over the 5.1.x config. If there isn't one, previous logic will continue to be used.

Testing passed on Windows

  1. Gramps 5.2.2 only
  2. Gramps 5.2.2 followed by Gramps 5.1.6
  3. Gramps 5.1.6 followed by Gramps 5.2.2
  • Create family trees in each version of Gramps and ensure that they are available when that version is launched.
  • Ensure that if 5.1.x is installed before 5.2.x, config is imported.
  • Testing on Windows
  • Testing on Linux
  • Testing on MacOS
  • Testing with GRAMPSHOME and SAFEMODE (cli?).

Thanks!

… locations

In an 5.2.x installations with XDG directory layout for data/config/cache, installing 5.1.x later would create a second config folder in the legacy layout, overriding the existing config.

This change makes it so that if an existing configuration exists for 5.2.x, it will be given preference over the 5.1.x config. If there isn't one, previous logic will continue to be used.
USER_DATA = os.path.join(GLib.get_user_data_dir(), "gramps")
USER_CONFIG = os.path.join(GLib.get_user_config_dir(), "gramps")
USER_CACHE = os.path.join(GLib.get_user_cache_dir(), "gramps")
if os.path.exists(USER_DATA) and os.path.exists(USER_CONFIG):
Copy link
Member Author

@hgohel hgohel Apr 18, 2024

Choose a reason for hiding this comment

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

First we check for the existence of XDG-based config created by 5.2.x or newer. If it exists, prefer it over legacy config folders.

The if condition could be merged into elif later on but at the cost of readability/understandability, so I left it this way with a pass statement.

@hgohel hgohel requested a review from Nick-Hall April 18, 2024 12:21
@hgohel hgohel added bug Needs Testing A pull request that needs further testing before it can be merged. labels Apr 18, 2024
@jralls
Copy link
Member

jralls commented Apr 23, 2024

macOS, at least in the AIO bundle, isn't affected by the bug and this change is harmless.

@hgohel
Copy link
Member Author

hgohel commented Apr 27, 2024

macOS, at least in the AIO bundle, isn't affected by the bug and this change is harmless.

Thanks for reviewing the change.

@Nick-Hall Nick-Hall removed the Needs Testing A pull request that needs further testing before it can be merged. label May 4, 2024
Copy link
Member

@Nick-Hall Nick-Hall left a comment

Choose a reason for hiding this comment

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

This works on Linux, but the GRAMPSHOME and SAFEMODE options are ignored if the new directory structure exists.

The GRAMPSHOME environment variable is used to specify a base directory for all data and configuration file storage. The safe mode works by setting this to an empty directory.

@hgohel
Copy link
Member Author

hgohel commented May 27, 2024

@Nick-Hall Returning to this defect after a while. Discovered a related bug while trying out safe mode, which affects the testing of this one so I think it needs to be fixed first: 13300. It would be very convenient if the root cause of that turns out to be the same as this one.

@hgohel
Copy link
Member Author

hgohel commented May 31, 2024

@Nick-Hall Turns out that this defect is a side-effect of 13300, and the fix for that is in PR #1726 (gramps52) and PR #1725 (master). I'm closing this PR in favor of those.

@hgohel hgohel closed this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants