#13901: File.chunks fails to read the entire file for some file-like objects
----------------------------------+-----------------------------------------
 Reporter:  ikelly                |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  File uploads/storage  |     Version:  SVN       
 Keywords:                        |       Stage:  Unreviewed
Has_patch:  1                     |  
----------------------------------+-----------------------------------------
 The File.chunks method gets the size of the file and then decrements a
 counter by the chunk size for each read until it reaches 0.  The problem
 is that the read method is not guaranteed to return the full amount
 requested, and so the amount read may be less than the chunk size,
 resulting in the counter being decremented erroneously.  I ran into this
 bug while using a file-like object that wraps a java.io.InputStream
 object, whose read method returns as soon as data is available.

 This patch is one possible solution, although it still has the problem
 that it will result in a busy-loop if the read method is entirely non-
 blocking.  It also potentially yields non-terminal chunks smaller than the
 chunk size, which may not be desirable.

 See also #9632, which may affect the implementation here if it is
 accepted.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13901>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to