You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Louis Marascio <ma...@gmail.com> on 2007/01/01 05:12:01 UTC

[FileUpload] Cleaning up temporary files if uploads are aborted

Hello,

I'm tinkering with FileUpload v1.1.1 and have the basic upload
working.  I noticed that if, during an upload, I click the stop button
in my browser the upload is aborted on the server side appropriately
w/ an exception. However, the temporary file that was being written by
the DiskFileItem is not being cleaned up in this situation. I can't
clean it up from my servlet handler since the FileItem was never added
to the collection, etc. It appears to be a trivial fix in
FileUploadBase.parseRequest().  Move the declaration of FileItem
outside of the try/catch, and, in the catch method do something along
the lines of:

if (item != null) item.delete();

I can submit a patch if desired.  I checked subversion to see how much
parseRequest() has changed and it appears to have been significantly
altered.  I'm not sure if there is much value submitting the patch
against 1.1.1 if a new release is imminent.

Am I missing something here? Is there some other way to get these
temporary files cleaned up in the case of an aborted or failed upload?

Thanks!

Louis

-- 
Louis R. Marascio
marascio@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org