This patch adresses what I think is a common use case: someone want the change an already uploaded file, but want to keep the same URL pointing to it. It adds a checkbox (enabled by default, changing existing behavior) which enables the substitution of files.
Files are now put in $CFG->dirroot/files/first-character-of-name/name/subdir-id/ so that files of the same name can be in different subdirectories.
If the substitute checkbox is not checked, the upload library chooses another name for the files (putting _1, _2 etc after the original name).
The patch also constructs the url in a different way: instead of using $file->originalname, it uses basename($file->location)) everywhere.