Add more precise check for reuse of log dir