Moved stat cache clearing into a method for consitent usage.
Fixes issue where incorrect cached filesize was reported when appending to file.
Thanks dogmatic69 for the patch.