Fix infinite recursion when a file is invalid (corrupted, empty, or mid-write)

Fixes some infinite recursion if the cache file was corrupted (someone touch-s the file)