state: fixed a state-dir creation race (bnc#866757)