Further guarded against race conditions when the file scan is over.