Better counting of file sizes

This now only counts each attachment_data row once.