[CORE] remove usage of Directory#fileExists

This commit removes the usage of #fileExists which has been
deprecated long ago an can be a source of race conditions.
This usePrimary parameter is only used by deleteFile. Maybe a cleaner fix here would be to completely remove the usePrimary parameter and to fix deleteFile to delete the file in all directories?