changeset 381:1c86bcb0b232

2003-2-1 Brian Masney <masneyb@gftp.org> * lib/protocols.c (gftp_get_dir_listing, gftp_get_all_subdirs) - don't modify the file variable if it begins with a /. Do not touch the destfile variable if it already exists
author masneyb
date Sun, 01 Feb 2004 22:14:15 +0000
parents 05ee37a5558b
children c5acf744ad79
files ChangeLog lib/protocols.c
diffstat 2 files changed, 42 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 28 23:46:28 2004 +0000
+++ b/ChangeLog	Sun Feb 01 22:14:15 2004 +0000
@@ -1,3 +1,8 @@
+2003-2-1 Brian Masney <masneyb@gftp.org>
+	* lib/protocols.c (gftp_get_dir_listing, gftp_get_all_subdirs) - don't
+	modify the file variable if it begins with a /. Do not touch the
+	destfile variable if it already exists
+
 2003-1-28 Brian Masney <masneyb@gftp.org>
 	* src/gtk/bookmarks.c src/gtk/dnd.c src/gtk/gftp-gtk.c
 	src/gtk/gftp-gtk.h src/gtk/gtkui.c src/gtk/menu-items.c 
@@ -2112,7 +2117,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.210 2004/01/28 23:46:25 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.211 2004/02/01 22:14:14 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/protocols.c	Wed Jan 28 23:46:28 2004 +0000
+++ b/lib/protocols.c	Sun Feb 01 22:14:15 2004 +0000
@@ -1748,15 +1748,20 @@
           (newsize = g_hash_table_lookup (dirhash, fle->file)) != NULL)
         fle->startsize = *newsize;
 
-      if (transfer->toreq)
+      if (transfer->toreq && fle->destfile == NULL)
         fle->destfile = gftp_build_path (transfer->toreq->directory, 
                                          fle->file, NULL);
 
-      newname = gftp_build_path (transfer->fromreq->directory,
-                                 fle->file, NULL);
-
-      g_free (fle->file);
-      fle->file = newname;
+      if (transfer->fromreq->directory != NULL &&
+          *transfer->fromreq->directory != '\0' &&
+          *fle->file != '/')
+        {
+          newname = gftp_build_path (transfer->fromreq->directory,
+                                     fle->file, NULL);
+
+          g_free (fle->file);
+          fle->file = newname;
+        }
 
       templist = g_list_append (templist, fle);
 
@@ -1779,7 +1784,7 @@
 gftp_get_all_subdirs (gftp_transfer * transfer,
                       void (*update_func) (gftp_transfer * transfer))
 {
-  char *oldfromdir, *oldtodir, *newname;
+  char *oldfromdir, *oldtodir, *newname, *pos;
   GList * templist, * lastlist;
   int forcecd, remotechanged;
   unsigned long *newsize;
@@ -1798,16 +1803,32 @@
   for (lastlist = transfer->files; ; lastlist = lastlist->next)
     {
       curfle = lastlist->data;
-      if (dirhash && 
-          (newsize = g_hash_table_lookup (dirhash, curfle->file)) != NULL)
+
+      if ((pos = strrchr (curfle->file, '/')) != NULL)
+        pos++;
+      else
+        pos = curfle->file;
+
+      if (dirhash != NULL && 
+          (newsize = g_hash_table_lookup (dirhash, pos)) != NULL)
         curfle->startsize = *newsize;
 
-      if (transfer->toreq)
-        curfle->destfile = g_strconcat (transfer->toreq->directory, "/", 
-                                        curfle->file, NULL);
-      newname = g_strconcat (transfer->fromreq->directory, transfer->fromreq->directory[strlen (transfer->fromreq->directory) - 1] == '/' ? "" : "/", curfle->file, NULL);
-      g_free (curfle->file);
-      curfle->file = newname;
+      if (curfle->size < 0 && GFTP_IS_CONNECTED (transfer->fromreq))
+        curfle->size = gftp_get_file_size (transfer->fromreq, curfle->file);
+
+      if (transfer->toreq && curfle->destfile == NULL)
+        curfle->destfile = gftp_build_path (transfer->toreq->directory, 
+                                            curfle->file, NULL);
+
+      if (transfer->fromreq->directory != NULL &&
+          *transfer->fromreq->directory != '\0' &&
+          *curfle->file != '/')
+        {
+          newname = gftp_build_path (transfer->fromreq->directory,
+                                     curfle->file, NULL);
+          g_free (curfle->file);
+          curfle->file = newname;
+        }
 
       if (lastlist->next == NULL)
         break;