The check was done too later. It turns out that createUser() had already created the dir, which caused the warning message to be shown every time.