Fixes T5912. When migrating files, we try to clean up the old data. However, this code isn't aware of reference counting, and unconditionally destroys the old data.
For example, if you migrate files F1 and F2 and they have the same data, we'll delete the shared data when we migrate F1. Then you'll get an error when you migrate F2.
Since this only affects duplicate files, it primarily hits default profile pictures, which are the most numerous duplicate files on most installs.