From f87347d44f3f2130dca76667e92430e7e1a0b53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 28 Apr 2024 20:19:45 +0200 Subject: [PATCH] core: fix `/upgrade` from previous releases (issue #2106) When 4 directories are received, the state directory is initialized with the data directory. This fixes the following error on `/upgrade`: Error: wrong number of paths for home directories (expected: 1 or 5, received: 4) --- src/core/core-dir.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/core-dir.c b/src/core/core-dir.c index af6d4e4bd..353f85579 100644 --- a/src/core/core-dir.c +++ b/src/core/core-dir.c @@ -336,6 +336,16 @@ dir_set_home_path (char *path) weechat_cache_dir = string_expand_home (paths[0]); weechat_runtime_dir = string_expand_home (paths[0]); } + else if (num_paths == 4) + { + /* compatibility with versions between 3.2 and 4.2.x */ + weechat_config_dir = string_expand_home (paths[0]); + weechat_data_dir = string_expand_home (paths[1]); + /* state dir = data dir by default */ + weechat_state_dir = string_expand_home (paths[1]); + weechat_cache_dir = string_expand_home (paths[2]); + weechat_runtime_dir = string_expand_home (paths[3]); + } else if (num_paths == 5) { weechat_config_dir = string_expand_home (paths[0]); @@ -346,6 +356,10 @@ dir_set_home_path (char *path) } else { + /* + * value of 4 is not mentioned in the message because it's kept only + * for compatibility with old releases, it should not be used any more + */ string_fprintf (stderr, _("Error: wrong number of paths for home directories " "(expected: 1 or 5, received: %d)\n"),