cache: safer handling of failing seek when writing revision branch cache
If the seek for some reason fails (perhaps because the file is too short to
search to the requested position), make sure we seek to the start and rewrite
everything.
It is unknown if this fixes a real problem that ever happened.