curl-users
Re: Patch to use filename from Content-disposition header
Date: Thu, 31 Dec 2009 21:49:21 +0100
Kamil Dudka wrote:
> The file may be created right after your check. And yes ... I know it's not
> so probable in the cURL tool, but a proper solution does not seem to be
> more complex than the current one.
Well, a "proper" solution won't bring much benefit. Since we don't have any sort of file locking, it doesn't matter if we detect&create the file atomically or not. Even if we do, nothing prevents another application from corrupting the file immediately after we create it.
The purpose of the filename check is just a helper to avoid surprises, such as when the server-provided filename is the same as an unrelated file you already have in the dir. Cross-application file coherence is not curl's job. We don't attempt it anywhere else, so I don't see a reason to do it here.
The cost of adding something like the suggested fdopen solution is code confusiion. If we add it here, future readers will ask themselves why it was done this way and if it is something that should be done elsewhere too.
-- Björn ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-users FAQ: http://curl.haxx.se/docs/faq.html Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2009-12-31