Mercurial > gftp.yaz
diff lib/cache.c @ 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 | c8ec7877432e |
children | c01d91c10f6c |
line wrap: on
line diff
--- 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';