avoid creating more upload threads than needed

If only a few files need to be uploaded, several threads might attempt
to upload the same file due to the loop-on-overflow behaviour of
offset-indexing in python lists.

Fix this by never creating more threads than files to be uploaded.