From dbebb64e322d51b4d3d1a31bcf8e3d129c6bc75a Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 7 Aug 2016 01:30:06 +0900 Subject: [PATCH] Change the enventor lock file path. If usr's system is shutdown unexpectedly, the lock file wont' be removed properly. Store the lock file in the OS temporary folder so it can be removed defintely when OS is turned off. --- src/bin/main.c | 51 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/bin/main.c b/src/bin/main.c index aad8b7a..23bf454 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -917,46 +917,30 @@ keygrabber_init(app_data *ad) static Eina_Bool enventor_lock_create(void) { - const char *config_home = efreet_config_home_get(); + //Tempoary Folder + const char *tmpdir = eina_environment_tmp_get(); //Exception 1 - //Create config home directory if it doesn't exist. - if (!config_home) + if (!tmpdir) { - EINA_LOG_ERR("No config home directory?! = %s", config_home); + EINA_LOG_ERR("No temporary directory?!"); return EINA_TRUE; } //Exception 2 - //Create config home directory if it doesn't exist. - if (!ecore_file_exists(config_home)) + //Create temp directory if it doesn't exist. + if (!ecore_file_path_dir_exists(tmpdir)) { - Eina_Bool success = ecore_file_mkdir(efreet_config_home_get()); + Eina_Bool success = ecore_file_mkdir(tmpdir); if (!success) { - EINA_LOG_ERR(_("Cannot create a config folder \"%s\""), - config_home); + EINA_LOG_ERR(_("Cannot create temporary diretory \"%s\""), tmpdir); return EINA_TRUE; } } char buf[PATH_MAX]; - snprintf(buf, sizeof(buf), "%s/enventor", config_home); - - //Exception 3 - //Create enventor config folder if it doesn't exist. - if (!ecore_file_exists(buf)) - { - Eina_Bool success = ecore_file_mkdir(buf); - if (!success) - { - EINA_LOG_ERR(_("Cannot create a enventor config folder \"%s\""), - buf); - return EINA_TRUE; - } - } - - snprintf(buf, sizeof(buf), "%s/enventor/"ENVENTOR_LOCK_FILE, config_home); + snprintf(buf, sizeof(buf), "%s/"ENVENTOR_LOCK_FILE, tmpdir); //Is there any other Enventor instance? if (ecore_file_exists(buf)) @@ -988,17 +972,22 @@ enventor_lock_remove() //You are not the owner of the lock. if (!own_lock) return; - const char *config_home = efreet_config_home_get(); - //Create config home directory if it doesn't exist. - if (!config_home || !ecore_file_exists(config_home)) + //Tempoary Folder + const char *tmpdir = eina_environment_tmp_get(); + if (!tmpdir) { - EINA_LOG_ERR("No config home directory?! = %s", config_home); + EINA_LOG_ERR("No temporary directory?!"); + return; + } + + if (!ecore_file_path_dir_exists(tmpdir)) + { + EINA_LOG_ERR("Cannot access to temporary directory?! = %s", tmpdir); return; } char buf[PATH_MAX]; - snprintf(buf, sizeof(buf), "%s/enventor/"ENVENTOR_LOCK_FILE, - efreet_config_home_get()); + snprintf(buf, sizeof(buf), "%s/"ENVENTOR_LOCK_FILE, tmpdir); //Just in case. if (!ecore_file_exists(buf))