changeset 253:a46c2eef5139

2003-8-11 Brian Masney <masneyb@gftp.org> * src/gtk/delete_dialog.c - don't attempt to clear the cache for the protocols that have the cache disabled * lib/local.c (local_chdir) - if request->directory == directory, don't free the request->directory and run getcwd(). This fixes a double free in the delete dialog in the GTK+ port * lib/gftp.h - added FIXME comment * lib/cache.c (gftp_delete_cache_entry) - added assertion
author masneyb
date Tue, 12 Aug 2003 00:04:37 +0000
parents 9db114fe50c6
children b0c531678919
files ChangeLog lib/cache.c lib/gftp.h lib/local.c src/gtk/delete_dialog.c
diffstat 5 files changed, 34 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Aug 09 05:44:36 2003 +0000
+++ b/ChangeLog	Tue Aug 12 00:04:37 2003 +0000
@@ -1,3 +1,15 @@
+2003-8-11 Brian Masney <masneyb@gftp.org>
+	* src/gtk/delete_dialog.c - don't attempt to clear the cache for the
+	protocols that have the cache disabled
+
+	* lib/local.c (local_chdir) - if request->directory == directory,
+	don't free the request->directory and run getcwd(). This fixes a double
+	free in the delete dialog in the GTK+ port
+
+	* lib/gftp.h - added FIXME comment
+
+	* lib/cache.c (gftp_delete_cache_entry) - added assertion
+
 2003-8-7 Brian Masney <masneyb@gftp.org>
 	* configure.in - HPUX fix
 
@@ -1454,7 +1466,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.131 2003/08/08 02:43:24 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.132 2003/08/12 00:04:36 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/cache.c	Sat Aug 09 05:44:36 2003 +0000
+++ b/lib/cache.c	Tue Aug 12 00:04:37 2003 +0000
@@ -291,7 +291,8 @@
 
 
 void
-gftp_delete_cache_entry (gftp_request * request, char *descr, int ignore_directory)
+gftp_delete_cache_entry (gftp_request * request, char *descr, 
+                         int ignore_directory)
 {
   char *oldindexfile, *newindexfile, buf[BUFSIZ], description[BUFSIZ];
   gftp_getline_buffer * rbuf;
@@ -300,8 +301,9 @@
   time_t now;
   int remove;
  
+  g_return_if_fail (request != NULL || descr != NULL);
+
   time (&now);
-
   if (request != NULL)
     {
       gftp_generate_cache_description (request, description, sizeof (description),
--- a/lib/gftp.h	Sat Aug 09 05:44:36 2003 +0000
+++ b/lib/gftp.h	Tue Aug 12 00:04:37 2003 +0000
@@ -445,7 +445,7 @@
   gftp_request * fromreq,
                * toreq;
 
-  unsigned int transfer_direction : 1,
+  unsigned int transfer_direction : 1, /* FIXME - take out */
                cancel : 1,
                ready : 1,
                started : 1,
--- a/lib/local.c	Sat Aug 09 05:44:36 2003 +0000
+++ b/lib/local.c	Tue Aug 12 00:04:37 2003 +0000
@@ -442,18 +442,21 @@
                           _("Successfully changed local directory to %s\n"),
                           directory);
 
-      if (getcwd (tempstr, sizeof (tempstr)) == NULL)
+      if (request->directory != directory)
         {
-          request->logging_function (gftp_logging_error, request,
-                            _("Could not get current working directory: %s\n"),
-                            g_strerror (errno));
-	  return (GFTP_ERETRYABLE);
+          if (getcwd (tempstr, sizeof (tempstr)) == NULL)
+            {
+              request->logging_function (gftp_logging_error, request,
+                             _("Could not get current working directory: %s\n"),
+                             g_strerror (errno));
+	      return (GFTP_ERETRYABLE);
+            }
+
+          if (request->directory)
+            g_free (request->directory);
+          request->directory = g_strdup (tempstr);
         }
 
-      if (request->directory)
-        g_free (request->directory);
-      request->directory = g_strdup (tempstr);
-
       return (0);
     }
   else
--- a/src/gtk/delete_dialog.c	Sat Aug 09 05:44:36 2003 +0000
+++ b/src/gtk/delete_dialog.c	Tue Aug 12 00:04:37 2003 +0000
@@ -54,7 +54,8 @@
            templist = templist->next);
 
       rmhash = g_hash_table_new (string_hash_function, string_hash_compare);
-      while (1)
+
+      for (; templist != NULL; templist = templist->prev)
         {
           tempfle = templist->data;
           if (tempfle->isdir)
@@ -62,7 +63,7 @@
           else
             success = gftp_remove_file (transfer->fromreq, tempfle->file);
 
-          if (success == 0)
+          if (success == 0 && transfer->fromreq->use_cache)
             {
               gftp_generate_cache_description (transfer->fromreq, description, 
                                                sizeof (description), 0);
@@ -73,10 +74,8 @@
                 }
             }
 
-          if (templist == transfer->files || 
-              !GFTP_IS_CONNECTED (transfer->fromreq))
+          if (!GFTP_IS_CONNECTED (transfer->fromreq))
             break;
-          templist = templist->prev;
         }
 
       g_hash_table_foreach (rmhash, delete_purge_cache, NULL);