Try and make the library updating robust against half-written files.