Revert "Revert "Shrink file if logical size is less than file size" (#5630)"
Revert "Revert "Shrink file if logical size is less than file size" (#5630)"

This reverts commit d808d899f935db00de81a72c940a7b7c9baaef63.

realm/realm-core,realm/realm-core,realm/realm-core,realm/realm-core,realm/realm-core,realm/realm-core,realm/realm-core