curl-library
Re: PATCH: ftp.c force directory exists on upload, minor bugfix.
Date: Tue, 5 Aug 2003 00:54:26 +0200 (CEST)
On Mon, 4 Aug 2003, Early Ehlinger wrote:
> 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
Thanks Early for your contribution!
Please use 'diff -u' and resend. Otherwise I'll get problems applying it in my
end!
> 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.
It is truly interesting that you post this only minutes after Salvatore
Sorrentino posted bug report #783116:
http://sourceforge.net/tracker/index.php?func=detail&aid=783116&group_id=976&atid=100976
I would still like to see a command line that shows this failure happening. It
would just rock to get a test case added that does it.
Then I would like a fix that only cures the problem without adding any new
features, please please post the new features patch separately!
> 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.
> 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 do not think this is a good default behaviour. We could discuss wheather
this is even necessary as an option, as you can easily add a custom MKD
command as a QUOTE one. Care to explain why you feel this feature should be
included?
To add a new option, you could simple check one existing option and see how it
is set in the src/curl.c client code's curl_easy_setopt() using the defines in
include/curl/curl.h ending up in lib/url.c's Curl_setopt() big switch() that
stores the setting... And the setting is then typically a struct field in the
SessionHandle's sub-struct 'UserDefined'. As found in lib/urldata.h! :-)
> 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.
Well, does all the tests still run fine? If you can't write the test case
yourself, can you at least provide enough information so that someone else can
write up one?
-- Daniel Stenberg -- curl: been grokking URLs since 1998 ------------------------------------------------------- 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/01Received on 2003-08-05