Wrong error when folder creation not possible due to permissions

Updated patch for #1174