Homology-directed repair protects the replicating genome from metabolic assaults