Code to rename/replace duplicate attachment files

Uses the existing AttachmentData#replaced_by mechanism to ensure we
can still continue to serve requests for the old filenames.