changeset 47:eec25f215772

2002-11-5 Brian Masney <masneyb@gftp.org> * lib/cache.c lib/gftp.h - added second argument ignore_directory to gftp_delete_cache_entry * src/gtk/menu-items.c (disconnect) - when disconnecting from the remote site, clear all cache entries for that site * src/gtk/delete_dialog.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c - pass a 0 as second argument to gftp_delete_cache_entry
author masneyb
date Tue, 05 Nov 2002 20:36:11 +0000
parents 3da7765bc439
children e5f6054590b5
files ChangeLog lib/cache.c lib/gftp.h src/gtk/delete_dialog.c src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c
diffstat 7 files changed, 36 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Nov 01 00:10:08 2002 +0000
+++ b/ChangeLog	Tue Nov 05 20:36:11 2002 +0000
@@ -1,3 +1,13 @@
+2002-11-5 Brian Masney <masneyb@gftp.org>
+	* lib/cache.c lib/gftp.h - added second argument ignore_directory to
+	gftp_delete_cache_entry
+
+	* src/gtk/menu-items.c (disconnect) - when disconnecting from the 
+	remote site, clear all cache entries for that site
+
+	* src/gtk/delete_dialog.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c -
+	pass a 0 as second argument to gftp_delete_cache_entry
+
 2002-10-31 Brian Masney <masneyb@gftp.org>
 	* lib/protocols.c (gftp_get_next_file) - don't use g_filename_to_utf8.
 	If g_locale_to_utf8 fails, print out a warning to the user on the 
@@ -127,7 +137,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.25 2002/11/01 00:10:08 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.26 2002/11/05 20:36:10 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/cache.c	Fri Nov 01 00:10:08 2002 +0000
+++ b/lib/cache.c	Tue Nov 05 20:36:11 2002 +0000
@@ -183,18 +183,19 @@
 
 
 void
-gftp_delete_cache_entry (gftp_request * request)
+gftp_delete_cache_entry (gftp_request * request, int ignore_directory)
 {
   char *oldindexfile, *newindexfile, *pos, buf[BUFSIZ], description[BUFSIZ];
   FILE *indexfd, *newfd;
   size_t len, buflen;
+  int remove;
 
   g_snprintf (description, sizeof (description), "%s://%s@%s:%d%s",
               gftp_cache_get_url_prefix (request),
               request->username == NULL ? "" : request->username,
               request->hostname == NULL ? "" : request->hostname,
               request->port, 
-              request->directory == NULL ? "" : request->directory);
+              ignore_directory || request->directory == NULL ? "" : request->directory);
 
   oldindexfile = expand_path (BASE_CONF_DIR "/cache/index.db");
   if ((indexfd = fopen (oldindexfile, "rb")) == NULL)
@@ -223,11 +224,24 @@
       if (!((pos = strrchr (buf, '\t')) != NULL && *(pos + 1) != '\0'))
         {
           printf (_("Error: Invalid line %s in cache index file\n"), buf);
-	  continue;
+          continue;
         }
 
-      if (buflen == pos - buf && strncmp (buf, description, pos - buf) == 0)
-	unlink (pos + 1);
+      remove = 0;
+      if (ignore_directory)
+        {
+          if (strncmp (buf, description, strlen (description)) == 0)
+            remove = 1;
+        }
+      else
+        {
+          if (buflen == pos - buf && strncmp (buf, description, pos - buf) == 0)
+            remove = 1;
+        }
+
+ 
+      if (remove)
+        unlink (pos + 1);
       else
         {
           buf[strlen (buf)] = '\n';
--- a/lib/gftp.h	Fri Nov 01 00:10:08 2002 +0000
+++ b/lib/gftp.h	Tue Nov 05 20:36:11 2002 +0000
@@ -481,7 +481,8 @@
 
 void gftp_clear_cache_files 		( void );
 
-void gftp_delete_cache_entry 		( gftp_request * request );
+void gftp_delete_cache_entry 		( gftp_request * request,
+					  int ignore_directory );
 
 /* config_file.c */
 void gftp_read_config_file 		( char **argv,
--- a/src/gtk/delete_dialog.c	Fri Nov 01 00:10:08 2002 +0000
+++ b/src/gtk/delete_dialog.c	Tue Nov 05 20:36:11 2002 +0000
@@ -260,7 +260,7 @@
   request = user_data;
   olddir = request->directory;
   request->directory = key;
-  gftp_delete_cache_entry (request);
+  gftp_delete_cache_entry (request, 0);
   request->directory = olddir;
   g_free (key);
 }
--- a/src/gtk/menu-items.c	Fri Nov 01 00:10:08 2002 +0000
+++ b/src/gtk/menu-items.c	Tue Nov 05 20:36:11 2002 +0000
@@ -136,6 +136,7 @@
   gftp_window_data * wdata;
 
   wdata = data;
+  gftp_delete_cache_entry (wdata->request, 1);
   gftp_disconnect (wdata->request);
   remove_files_window (wdata);
   update_window (wdata);
--- a/src/gtk/misc-gtk.c	Fri Nov 01 00:10:08 2002 +0000
+++ b/src/gtk/misc-gtk.c	Tue Nov 05 20:36:11 2002 +0000
@@ -244,7 +244,7 @@
     return;
   gtk_clist_freeze (GTK_CLIST (wdata->listbox));
   remove_files_window (wdata);
-  gftp_delete_cache_entry (wdata->request);
+  gftp_delete_cache_entry (wdata->request, 0);
   ftp_list_files (wdata, 0);
   gtk_clist_thaw (GTK_CLIST (wdata->listbox));
   fix_display ();
--- a/src/gtk/mkdir_dialog.c	Fri Nov 01 00:10:08 2002 +0000
+++ b/src/gtk/mkdir_dialog.c	Tue Nov 05 20:36:11 2002 +0000
@@ -81,7 +81,7 @@
 
   if ((int) generic_thread (do_make_dir_thread, wdata))
     {
-      gftp_delete_cache_entry (wdata->request);
+      gftp_delete_cache_entry (wdata->request, 0);
       refresh (wdata);
     }
 }