may be move it up before upload() function is called (around line 515) so that we won't added the invalid file to the wiki.