fix logical error on dir state recovery
add missing error check on mkdir