fixed a logic bug in repairing missing files