another FTP reget patch



Hi,

the attached patch fixes the FTP Reget issue, hopefully better way than
my previous solution. It allows using lseek() on a linear file before
the first read operation. No changes of mc_open() semantics are needed
this time, only one-line modifications of ftpfs & fish. Also includes a
cosmetic fix of the copy progress bar.

Best regards,
-- 
Jindrich Makovicka
Index: vfs/direntry.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/direntry.c,v
retrieving revision 1.116
diff -u -r1.116 direntry.c
--- vfs/direntry.c	22 Feb 2005 18:35:23 -0000	1.116
+++ vfs/direntry.c	14 May 2005 18:34:14 -0000
@@ -779,10 +779,7 @@
     if (IS_LINEAR (flags)) {
 	if (MEDATA->linear_start) {
 	    print_vfs_message (_("Starting linear transfer..."));
-	    if (!MEDATA->linear_start (me, fh, 0)) {
-		g_free (fh);
-		return NULL;
-	    }
+	    fh->linear = LS_LINEAR_PREOPEN;
 	}
     } else if ((MEDATA->fh_open)
 	       && (MEDATA->fh_open (me, fh, flags, mode))) {
@@ -811,6 +808,12 @@
     int n;
     struct vfs_class *me = FH_SUPER->me;
 
+    if (FH->linear == LS_LINEAR_PREOPEN) {
+	if (MEDATA->linear_start)
+	    if (!MEDATA->linear_start (me, FH, FH->pos))
+		return -1;
+    }
+
     if (FH->linear == LS_LINEAR_CLOSED)
         vfs_die ("linear_start() did not set linear_state!");
 
@@ -852,6 +855,9 @@
 {
     off_t size = FH->ino->st.st_size;
 
+    if (FH->linear == LS_LINEAR_OPEN)
+        vfs_die ("cannot lseek() after linear_read!");
+
     if (FH->handle != -1){	/* If we have local file opened, we want to work with it */
 	int retval = lseek (FH->handle, offset, whence);
 	if (retval == -1)
Index: vfs/fish.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/fish.c,v
retrieving revision 1.103
diff -u -r1.103 fish.c
--- vfs/fish.c	22 Feb 2005 18:38:58 -0000	1.103
+++ vfs/fish.c	14 May 2005 18:34:14 -0000
@@ -682,7 +682,7 @@
 
 		if (!FH->linear)
 		    vfs_die ("You may not do this");
-		if (FH->linear == LS_LINEAR_CLOSED)
+		if (FH->linear == LS_LINEAR_CLOSED || FH->linear == LS_LINEAR_PREOPEN)
 		    return 0;
 
 		v = vfs_s_select_on_two (FH_SUPER->u.fish.sockr, 0);
Index: vfs/ftpfs.c
===================================================================
RCS file: /cvsroot/mc/mc/vfs/ftpfs.c,v
retrieving revision 1.177
diff -u -r1.177 ftpfs.c
--- vfs/ftpfs.c	13 May 2005 20:32:10 -0000	1.177
+++ vfs/ftpfs.c	14 May 2005 18:34:14 -0000
@@ -1444,7 +1444,7 @@
 		
 		if (!FH->linear)
 		    vfs_die ("You may not do this");
-		if (FH->linear == LS_LINEAR_CLOSED)
+		if (FH->linear == LS_LINEAR_CLOSED || FH->linear == LS_LINEAR_PREOPEN)
 		    return 0;
 
 		v = vfs_s_select_on_two (FH->u.ftp.sock, 0);
Index: vfs/xdirentry.h
===================================================================
RCS file: /cvsroot/mc/mc/vfs/xdirentry.h,v
retrieving revision 1.51
diff -u -r1.51 xdirentry.h
--- vfs/xdirentry.h	18 Feb 2005 21:15:37 -0000	1.51
+++ vfs/xdirentry.h	14 May 2005 18:34:15 -0000
@@ -202,6 +202,7 @@
 
 #define LS_NOT_LINEAR 0
 #define LS_LINEAR_CLOSED 1
-#define LS_LINEAR_OPEN 2
+#define LS_LINEAR_PREOPEN 2
+#define LS_LINEAR_OPEN 3
 
 #endif
Index: src/file.c
===================================================================
RCS file: /cvsroot/mc/mc/src/file.c,v
retrieving revision 1.140
diff -u -r1.140 file.c
--- src/file.c	11 May 2005 01:16:59 -0000	1.140
+++ src/file.c	14 May 2005 18:34:15 -0000
@@ -737,10 +737,10 @@
 
 	    file_progress_set_stalled_label (ctx, stalled_msg);
 	    return_status = file_progress_show_bytes (ctx, *progress_bytes +
-		    n_read_total, ctx->progress_bytes);
+		    n_read_total + ctx->do_reget, ctx->progress_bytes);
 	    if (return_status == FILE_CONT) {
 		return_status =
-		    file_progress_show (ctx, n_read_total, file_size);
+		    file_progress_show (ctx, n_read_total + ctx->do_reget, file_size);
 	    }
 	    mc_refresh ();
 	    if (return_status != FILE_CONT)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]