Just a couple of issues I’ve noticed.
Deleting the attached file is ineffective (in admin Attach File meta box). You can overwrite it, but I prefer to trash it before uploading a new file to ‘flush’ any meta data.
Not sure if this is related, but it would seem that the ‘package_size meta’ is not being flushed or renewed after replacing the attached file. It disappears when referencing it with ‘get_package_data( $id, ‘package_size’ );’ (i.e. no value is found).
Best always
Jon