We really need to use lock in this block avoiding access by another thread? The only issue if many thread access in same time is check for tmpdir twice.