Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ftp Invalidate remote directory completion cache if ...



details:   https://anonhg.NetBSD.org/src/rev/48f2326fd2e9
branches:  trunk
changeset: 550142:48f2326fd2e9
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jul 31 07:06:41 2003 +0000

description:
Invalidate remote directory completion cache if any command which
may change the remote contents completes successfully, including:
del, mdel, ren, mkdir, rmdir, quote, and all upload commands
Patch from Yar Tikhiy <yar%comp.chem.msu.su@localhost>.

diffstat:

 usr.bin/ftp/cmds.c |  32 ++++++++++++++++++++++----------
 usr.bin/ftp/ftp.c  |   5 +++--
 2 files changed, 25 insertions(+), 12 deletions(-)

diffs (136 lines):

diff -r 84d8842ea51f -r 48f2326fd2e9 usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Thu Jul 31 06:57:07 2003 +0000
+++ b/usr.bin/ftp/cmds.c        Thu Jul 31 07:06:41 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $ */
+/*     $NetBSD: cmds.c,v 1.101 2003/07/31 07:06:41 lukem Exp $ */
 
 /*-
  * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.101 2003/07/31 07:06:41 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -1184,7 +1184,8 @@
                code = -1;
                return;
        }
-       (void)command("DELE %s", argv[1]);
+       if (command("DELE %s", argv[1]) == COMPLETE)
+               dirchange = 1;
 }
 
 /*
@@ -1214,7 +1215,8 @@
                        continue;
                }
                if (mflag && confirm(argv[0], cp)) {
-                       (void)command("DELE %s", cp);
+                       if (command("DELE %s", cp) == COMPLETE)
+                               dirchange = 1;
                        if (!mflag && fromatty) {
                                ointer = interactive;
                                interactive = 1;
@@ -1244,8 +1246,9 @@
                code = -1;
                return;
        }
-       if (command("RNFR %s", argv[1]) == CONTINUE)
-               (void)command("RNTO %s", argv[2]);
+       if (command("RNFR %s", argv[1]) == CONTINUE &&
+           command("RNTO %s", argv[2]) == COMPLETE)
+               dirchange = 1;
 }
 
 /*
@@ -1552,6 +1555,7 @@
 void
 makedir(int argc, char *argv[])
 {
+       int r;
 
        if (argc == 0 || argc > 2 ||
            (argc == 1 && !another(&argc, &argv, "directory-name"))) {
@@ -1559,12 +1563,15 @@
                code = -1;
                return;
        }
-       if (command("MKD %s", argv[1]) == ERROR && code == 500) {
+       r = command("MKD %s", argv[1]);
+       if (r == ERROR && code == 500) {
                if (verbose)
                        fputs("MKD command not recognized, trying XMKD.\n",
                            ttyout);
-               (void)command("XMKD %s", argv[1]);
+               r = command("XMKD %s", argv[1]);
        }
+       if (r == COMPLETE)
+               dirchange = 1;
 }
 
 /*
@@ -1573,6 +1580,7 @@
 void
 removedir(int argc, char *argv[])
 {
+       int r;
 
        if (argc == 0 || argc > 2 ||
            (argc == 1 && !another(&argc, &argv, "directory-name"))) {
@@ -1580,12 +1588,15 @@
                code = -1;
                return;
        }
-       if (command("RMD %s", argv[1]) == ERROR && code == 500) {
+       r = command("RMD %s", argv[1]);
+       if (r == ERROR && code == 500) {
                if (verbose)
                        fputs("RMD command not recognized, trying XRMD.\n",
                            ttyout);
-               (void)command("XRMD %s", argv[1]);
+               r = command("XRMD %s", argv[1]);
        }
+       if (r == COMPLETE)
+               dirchange = 1;
 }
 
 /*
@@ -1642,6 +1653,7 @@
                while (getreply(0) == PRELIM)
                        continue;
        }
+       dirchange = 1;
 }
 
 void
diff -r 84d8842ea51f -r 48f2326fd2e9 usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Thu Jul 31 06:57:07 2003 +0000
+++ b/usr.bin/ftp/ftp.c Thu Jul 31 07:06:41 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.120 2002/06/05 10:20:49 lukem Exp $  */
+/*     $NetBSD: ftp.c,v 1.121 2003/07/31 07:06:41 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.120 2002/06/05 10:20:49 lukem Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.121 2003/07/31 07:06:41 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -745,6 +745,7 @@
                if (command("%s", cmd) != PRELIM)
                        goto cleanupsend;
        }
+       dirchange = 1;
        dout = dataconn(lmode);
        if (dout == NULL)
                goto abort;



Home | Main Index | Thread Index | Old Index