cURL / Mailing Lists / curl-library / Single Mail

curl-library

PATCH: ftp.c force directory exists on upload, minor bugfix.

From: Early Ehlinger <early_at_respower.com>
Date: Mon, 4 Aug 2003 17:11:11 -0500

Attached file was generated with this command line:

diff curl-7.10.6/lib/ftp.c orig/curl-7.10.6/lib/ftp.c > ftp.diff

------------
BUG:
When uploading with libcurl, I found that if you reuse the connection,
ftp->dirs does not get reset correctly and as a result files often end up in
the wrong spot on the remote server.

FIX:
I refactored the code a little bit, adding function "ftp_free_dirs( FTP*
ftp )", which clears out ftp->dirs. I then replaced all the locations that
duplicated this code with calls to ftp_free_dirs and added an extra call in
a location that fixes the bug.

------------
NEW FEATURE:
I added two functions, ftp_mkd and ftp_force_cwd. ftp_mkd does what you
would expect - it creates a directory. ftp_force_cwd does a CWD, and does a
MKD if necessary.

CURRENT PROBLEMS WITH PATCH:
I updated the code that calls ftp_cwd before an upload to call ftp_force_cwd
instead. This really should be an option instead, but as I'm still a
libcurl newbie I do not feel comfortable enough with the sources to make
this change. If somebody would like to point me in the right direction, I
should have the time in the next few days to make this patch a little more
robust.

I'm not sure if the ftp_free_dirs call that I added (as opposed to simply
refactored in) is appropriate in the context of a non-reused connection or a
download. It seems to work on my first connection just fine, but I don't
have the time to write test cases to verify that it's downloading
appropriately.

--
-- Early Ehlinger CEO, ResPower Inc - Toll-Free : 866-737-7697
-- www.respower.com -- 500+ GHz Supercomputer Starting At USD$0.50/GHz*Hour
begin 666 ftp.diff
M,3 T+#$P-60Q,#,*/"!S=&%T:6,@0U523&-O9&4_at_9G1P7VUK9"AS=')U8W0@
M8V]N;F5C=&1A=&$@*F-O;FXL(&-H87(@*G!A=&@I.PH\('-T871I8R!#55),
M8V]D92!F='!?9F]R8V5?8W=D*'-T<G5C="!C;VYN96-T9&%T82 J8V]N;BP@
M8VAA<B J<&%T:"D["C$Q,"PQ,3%D,3 W"CP@=F]I9"!F='!?9G)E95]D:7)S
M*"!S=')U8W0_at_1E10*B!F=' @*3L*/" *,3DX-6,Q.3_at_Q"CP@(" @(&EF("@H
M<F5S=6QT(#T_at_9G1P7V9O<F-E7V-W9"AC;VYN+"!F=' M/F5N=')Y<&%T:"DI
M("$]($-54DQ%7T]+*0HM+2T*/B @(" @:68@*"AR97-U;'0@/2!F='!?8W=D
M*&-O;FXL(&9T<"T^96YT<GEP871H*2D@(3T_at_0U523$5?3TLI"C$Y.3(L,3DY
M,V,Q.3_at_X+#$Y.3 */" @(" @("!I9B H*')E<W5L=" ](&9T<%]F;W)C95]C
M=V0H8V]N;BP_at_9G1P+3YD:7)S6VE=*2D@(3T_at_0U523$5?3TL@*0H\( ER971U
M<FX@<F5S=6QT.PHM+2T*/B @(" @(" O*B!21D,@,3<S."!S87ES(&5M<'1Y
M(&-O;7!O;F5N=',@<VAO=6QD(&)E(')E<W!E8W1E9"!T;V\@*B\*/B @(" @
M("!I9B H*')E<W5L=" ](&9T<%]C=V0H8V]N;BP_at_9G1P+3YD:7)S6VE=*2D@
M(3T_at_0U523$5?3TLI"CX@(" @(" @("!R971U<FX@<F5S=6QT.PHR,3,X+#(Q
M,SED,C$S- H\(" @9G1P7V9R965?9&ER<R@@9G1P("D["CP@"C(Q-S-C,C$V
M."PR,3<R"CP@(" @(" @9G1P7V9R965?9&ER<R@@9G1P("D["BTM+0H^(" @
M(" @(&EN="!I.PH^(" @(" @(&9O<B H:3TP.VD\<&%T:%]P87)T.VDK*RD@
M>R O*B!F<F5E('!R979I;W5S('!A<G1S("HO"CX@(" @(" @("!F<F5E*&9T
M<"T^9&ER<UMI72D["CX@(" @(" @("!F=' M/F1I<G-;:5T]3E5,3#L*/B @
M(" @("!]"C(Q.#-C,C$X,BPR,3_at_V"CP@(" @(" @9G1P7V9R965?9&ER<R@@
M9G1P("D["BTM+0H^(" @(" @(&EN="!I.PH^(" @(" @(&9O<B H:3TP.VD\
M<&%T:%]P87)T.VDK*RE["CX@(" @(" @("!F<F5E*&9T<"T^9&ER<UMI72D[
M"CX@(" @(" @("!F=' M/F1I<G-;:5T]3E5,3#L*/B @(" @("!]"C(R.#0L
M,C(Y-F,R,C_at_W+#(R.#@*/" @(" @9G1P7V9R965?9&ER<R@@9G1P("D["CP@
M"CP@(" @(&9T<"T^9FEL92 ]($Y53$P[("\J('IE<F\@*B\*/" @('T*/" @
M(')E='5R;B!#55),15]/2SL*/"!]"CP@"CP@=F]I9"!F='!?9G)E95]D:7)S
M*"!S=')U8W0_at_1E10*B!F=' @*0H\('L*/" @(&EN="!I.PH\(" @9F]R*"!I
M/3 [9G1P+3YD:7)S6VE=.VDK*RD*/" @(" @>PH\(" @(" @(&9R964H(&9T
M<"T^9&ER<UMI72D["BTM+0H^(" @("!F;W(@*&D],#MF=' M/F1I<G-;:5T[
M:2LK*7L*/B @(" @("!F<F5E*&9T<"T^9&ER<UMI72D["C(R.3DL,C,Q,V0R
M,CDP"CP@?0H\( H\($-54DQC;V1E(&9T<%]M:V0H<W1R=6-T(&-O;FYE8W1D
M871A("IC;VYN+"!C:&%R("IP871H*0H\('L*/" @($-54DQC;V1E(')E<W5L
M=#U#55),15]/2SL*/" @(&EN="!F='!C;V1E.R O*B!F;W(@9G1P('-T871U
M<R J+PH\(" @<W-I>F5?="!N<F5A9#L*/" @(&-H87(@*F)U9B ](&-O;FXM
M/F1A=&$M/G-T871E+F)U9F9E<CL*/" */" @("\J($-R96%T92!A(&1I<F5C
M=&]R>2!O;B!T:&4@<F5M;W1E('-E<G9E<B J+PH\(" @1E104T5.1$8H8V]N
M;BP@(DU+1" E<R(L('!A=&@I.PH\( H\(" @<F5S=6QT(#T_at_0W5R;%]'971&
M5%!297-P;VYS92_at_F;G)E860L(&-O;FXL("9F='!C;V1E*3L*/" @(&EF*')E
M<W5L="D*/" @(" @<F5T=7)N(')E<W5L=#L*,C,Q-2PR,S(U8S(R.3(*/" @
M('-W:71C:"AF='!C;V1E*2!["CP@("!C87-E(#(U-SH*/" @(" @>PH\(" @
M(" @("\J('-U8V-E<W,A("HO"CP@(" @(" @:6YF;V8H(&-O;FXM/F1A=&$@
M+" B0W)E871E9"!296UO=&4_at_1&ER96-T;W)Y("5S7&XB("P@<&%T:" I.PH\
M(" @("!]"CP@(" @(&)R96%K.PH\(" @9&5F875L=#H*/" @(" @:6YF;V8H
M8V]N;BT^9&%T82P@(G5N<F5C;V=N:7IE9"!-2T0@<F5S<&]N<V4@)61<;B(L
M(')E<W5L=" I.PH\(" @("!R97-U;'0@/2!^0U523$5?3TL["CP@(" @(&)R
M96%K.PHM+2T*/B @(" @9G1P+3YF:6QE(#T_at_3E5,3#L@+RH@>F5R;R J+PHR
M,S(W+#(S,SEC,C(Y- H\(" @<F5T=7)N("!R97-U;'0["CP@?0H\( H\($-5
M4DQC;V1E(&9T<%]F;W)C95]C=V0H<W1R=6-T(&-O;FYE8W1D871A("IC;VYN
M+"!C:&%R("IP871H("D*/"!["CP@("!#55),8V]D92!R97-U;'0]0U523$5?
M3TL["CP@("!I9B H($-54DQ%7T]+("$]("@@<F5S=6QT(#T_at_9G1P7V-W9"@@
M8V]N;B L('!A=&@@*2 I("D*/" @(" @>PH\(" @(" @(&EF("@@0U523$5?
M3TL@(3T@*"!R97-U;'0@/2!F='!?;6MD*"!C;VYN("P@<&%T:" I("D@*0H\
M( ER971U<FX@<F5S=6QT.PH\(" @(" @(')E<W5L=" ](&9T<%]C=V0H(&-O
M;FX@+"!P871H("D["CP@(" @('T*/" @(')E='5R;B!R97-U;'0["BTM+0H^
4(" @<F5T=7)N($-54DQ%7T]+.PH`
`
end
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-05