mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Don't exit after migration of configuration files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
3f8e561e17
commit
f9b6abde52
@ -100,9 +100,7 @@ void mc_config_init_config_paths (GError ** error);
|
||||
|
||||
void mc_config_deinit_config_paths (void);
|
||||
|
||||
gboolean mc_config_deprecated_dir_present (void);
|
||||
|
||||
void mc_config_migrate_from_old_place (GError ** error);
|
||||
gboolean mc_config_migrate_from_old_place (GError ** error, char **msg);
|
||||
|
||||
const char *mc_config_get_data_path (void);
|
||||
|
||||
|
@ -266,6 +266,21 @@ mc_config_fix_migrated_rules (void)
|
||||
}
|
||||
#endif /* MC_HOMEDIR_XDG */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
mc_config_deprecated_dir_present (void)
|
||||
{
|
||||
char *old_dir;
|
||||
gboolean is_present;
|
||||
|
||||
old_dir = mc_config_get_deprecated_path ();
|
||||
is_present = g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
|
||||
g_free (old_dir);
|
||||
|
||||
return is_present && !config_dir_present;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -423,12 +438,15 @@ mc_config_get_path (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_config_migrate_from_old_place (GError ** error)
|
||||
gboolean
|
||||
mc_config_migrate_from_old_place (GError ** error, char **msg)
|
||||
{
|
||||
char *old_dir;
|
||||
size_t rule_index;
|
||||
|
||||
if (!mc_config_deprecated_dir_present ())
|
||||
return FALSE;
|
||||
|
||||
old_dir = mc_config_get_deprecated_path ();
|
||||
|
||||
g_free (mc_config_init_one_config_path (mc_config_str, EDIT_DIR, error));
|
||||
@ -437,6 +455,9 @@ mc_config_migrate_from_old_place (GError ** error)
|
||||
g_free (mc_config_init_one_config_path (mc_data_str, EDIT_DIR, error));
|
||||
#endif /* MC_HOMEDIR_XDG */
|
||||
|
||||
if (*error != NULL)
|
||||
return FALSE;
|
||||
|
||||
for (rule_index = 0; mc_config_files_reference[rule_index].old_filename != NULL; rule_index++)
|
||||
{
|
||||
char *old_name;
|
||||
@ -460,38 +481,19 @@ mc_config_migrate_from_old_place (GError ** error)
|
||||
}
|
||||
|
||||
#ifdef MC_HOMEDIR_XDG
|
||||
g_propagate_error (error,
|
||||
g_error_new (MC_ERROR, 0,
|
||||
_
|
||||
("Your old settings were migrated from %s\n"
|
||||
*msg = g_strdup_printf (_("Your old settings were migrated from %s\n"
|
||||
"to Freedesktop recommended dirs.\n"
|
||||
"To get more info, please visit\n"
|
||||
"http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html"),
|
||||
old_dir));
|
||||
old_dir);
|
||||
#else /* MC_HOMEDIR_XDG */
|
||||
g_propagate_error (error,
|
||||
g_error_new (MC_ERROR, 0,
|
||||
_
|
||||
("Your old settings were migrated from %s\n"
|
||||
"to %s\n"), old_dir, mc_config_str));
|
||||
*msg = g_strdup_printf (_("Your old settings were migrated from %s\n"
|
||||
"to %s\n"), old_dir, mc_config_str);
|
||||
#endif /* MC_HOMEDIR_XDG */
|
||||
|
||||
g_free (old_dir);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_config_deprecated_dir_present (void)
|
||||
{
|
||||
char *old_dir;
|
||||
gboolean is_present;
|
||||
|
||||
old_dir = mc_config_get_deprecated_path ();
|
||||
is_present = g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
|
||||
g_free (old_dir);
|
||||
|
||||
return is_present && !config_dir_present;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
14
src/main.c
14
src/main.c
@ -238,6 +238,8 @@ int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean config_migrated = FALSE;
|
||||
char *config_migrate_msg;
|
||||
int exit_code = EXIT_FAILURE;
|
||||
|
||||
/* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
|
||||
@ -282,8 +284,8 @@ main (int argc, char *argv[])
|
||||
goto startup_exit_falure;
|
||||
|
||||
mc_config_init_config_paths (&error);
|
||||
if (error == NULL && mc_config_deprecated_dir_present ())
|
||||
mc_config_migrate_from_old_place (&error);
|
||||
if (error == NULL)
|
||||
config_migrated = mc_config_migrate_from_old_place (&error, &config_migrate_msg);
|
||||
if (error != NULL)
|
||||
{
|
||||
mc_event_deinit (NULL);
|
||||
@ -385,11 +387,17 @@ main (int argc, char *argv[])
|
||||
#endif /* ENABLE_SUBSHELL */
|
||||
mc_prompt = (geteuid () == 0) ? "# " : "$ ";
|
||||
|
||||
if (config_migrated)
|
||||
{
|
||||
message (D_ERROR, _("Warning"), "%s", config_migrate_msg);
|
||||
g_free (config_migrate_msg);
|
||||
}
|
||||
|
||||
/* Program main loop */
|
||||
if (mc_global.midnight_shutdown)
|
||||
exit_code = EXIT_SUCCESS;
|
||||
else
|
||||
exit_code = do_nc ()? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
exit_code = do_nc () ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
||||
/* Save the tree store */
|
||||
(void) tree_store_save ();
|
||||
|
Loading…
Reference in New Issue
Block a user