[gnome-session] Allow saved-session to be a symlink
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] Allow saved-session to be a symlink
- Date: Thu, 31 Jan 2013 21:56:55 +0000 (UTC)
commit b733c2ee519b65c3c4eab0d0e93056412f995f3f
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 31 15:36:04 2013 -0500
Allow saved-session to be a symlink
https://bugzilla.gnome.org/show_bug.cgi?id=613270
gnome-session/gsm-session-save.c | 32 ++++----------------------------
gnome-session/gsm-util.c | 6 ------
2 files changed, 4 insertions(+), 34 deletions(-)
---
diff --git a/gnome-session/gsm-session-save.c b/gnome-session/gsm-session-save.c
index fdaf24e..69d0d5b 100644
--- a/gnome-session/gsm-session-save.c
+++ b/gnome-session/gsm-session-save.c
@@ -33,7 +33,7 @@ static gboolean gsm_session_clear_saved_session (const char *directory,
GHashTable *discard_hash);
typedef struct {
- char *dir;
+ const char *dir;
GHashTable *discard_hash;
GError **error;
} SessionSaveData;
@@ -135,7 +135,6 @@ gsm_session_save (GsmStore *client_store,
GError **error)
{
const char *save_dir;
- char *tmp_dir;
SessionSaveData data;
g_debug ("GsmSessionSave: Saving session");
@@ -146,41 +145,18 @@ gsm_session_save (GsmStore *client_store,
return;
}
- tmp_dir = gsm_util_get_empty_tmp_session_dir ();
- if (tmp_dir == NULL) {
- g_warning ("GsmSessionSave: cannot create new saved session directory");
- return;
- }
-
- /* save the session in a temp directory, and remember the discard
- * commands */
- data.dir = tmp_dir;
+ data.dir = save_dir;
data.discard_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
+ /* remove old saved session */
+ gsm_session_clear_saved_session (save_dir, data.discard_hash);
data.error = error;
gsm_store_foreach (client_store,
(GsmStoreFunc) save_one_client,
&data);
- if (!*error) {
- /* remove the old saved session */
- gsm_session_clear_saved_session (save_dir, data.discard_hash);
-
- /* rename the temp session dir */
- if (g_file_test (save_dir, G_FILE_TEST_IS_DIR))
- g_rmdir (save_dir);
- g_rename (tmp_dir, save_dir);
- } else {
- g_warning ("GsmSessionSave: error saving session: %s", (*error)->message);
- /* FIXME: we should create a hash table filled with the discard
- * commands that are in desktop files from save_dir. */
- gsm_session_clear_saved_session (tmp_dir, NULL);
- g_rmdir (tmp_dir);
- }
-
g_hash_table_destroy (data.discard_hash);
- g_free (tmp_dir);
}
static gboolean
diff --git a/gnome-session/gsm-util.c b/gnome-session/gsm-util.c
index 402ac69..b4036f6 100644
--- a/gnome-session/gsm-util.c
+++ b/gnome-session/gsm-util.c
@@ -100,15 +100,9 @@ gsm_util_find_desktop_file_for_app_name (const char *name,
static gboolean
ensure_dir_exists (const char *dir)
{
- if (g_file_test (dir, G_FILE_TEST_IS_DIR))
- return TRUE;
-
if (g_mkdir_with_parents (dir, 0755) == 0)
return TRUE;
- if (errno == EEXIST)
- return g_file_test (dir, G_FILE_TEST_IS_DIR);
-
g_warning ("GsmSessionSave: Failed to create directory %s: %s", dir, strerror (errno));
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]