From 5b6d6709a949784250886a7a9cfe7f356c43c753 Mon Sep 17 00:00:00 2001 From: Robie Basak Date: Wed, 18 Nov 2009 22:04:37 +0000 Subject: [PATCH] smbfs/sshfs save problem --- debian/changelog | 7 +++++++ gedit/gedit-local-document-saver.c | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 27191f5..ee940ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +gedit (2.28.0-0ubuntu2~basak1) karmic; urgency=low + + * Patched for smbfs/sshfs save problem (lp: #34813). From Red Hat's fix in + RHBA-2008:0019-2. + + -- Robie Basak Wed, 18 Nov 2009 22:02:35 +0000 + gedit (2.28.0-0ubuntu2) karmic; urgency=low * No change upload to build using the current cdbs, it will fix default diff --git a/gedit/gedit-local-document-saver.c b/gedit/gedit-local-document-saver.c index 82017a2..ea20633 100644 --- a/gedit/gedit-local-document-saver.c +++ b/gedit/gedit-local-document-saver.c @@ -477,6 +477,13 @@ save_existing_local_file (GeditLocalDocumentSaver *lsaver) goto out; } + /* close the file so we can rename it */ + if (close (lsaver->priv->fd) != 0) + { + g_warning("couldn't close"); + } + lsaver->priv->fd = -1; + /* original -> backup */ if (rename (lsaver->priv->local_path, backup_filename) != 0) { @@ -494,6 +501,12 @@ save_existing_local_file (GeditLocalDocumentSaver *lsaver) goto out; } + /* close tmpfd so we can rename it */ + if (close (tmpfd) != 0) + { + g_warning("could not close tmpfd"); + } + /* tmp -> original */ if (rename (tmp_filename, lsaver->priv->local_path) != 0) { @@ -517,7 +530,7 @@ save_existing_local_file (GeditLocalDocumentSaver *lsaver) g_free (tmp_filename); /* restat and get the mime type */ - if (fstat (tmpfd, &new_statbuf) != 0) + if (stat (lsaver->priv->local_path, &new_statbuf) != 0) { g_set_error (&lsaver->priv->error, G_IO_ERROR, @@ -719,7 +732,7 @@ save_existing_local_file (GeditLocalDocumentSaver *lsaver) lsaver->priv->content_type = get_slow_content_type (saver->uri); out: - if (close (lsaver->priv->fd)) + if (lsaver->priv->fd >= 0 && close (lsaver->priv->fd)) g_warning ("File '%s' has not been correctly closed: %s", saver->uri, g_strerror (errno)); -- 1.6.3.3