 	host = config.basePath ? "#{req.protocol}://#{req.header 'host'}"
 	versionNumber = packageList?[req.params[0]]?.packageinformation?.version[0]
 	unless versionNumber?
-		res.send 404, '404 Not Found' if err?
+		res.send 404, '404 Not Found'
 		return
 	res.redirect 301, "#{host}/#{req.params[0]}/#{versionNumber.replace (new RegExp ' ', 'g'), '_'}"
 

				if err?
					callback "Error parsing package.xml of #{filename}: #{err}", null
					return

				# push the parsed contents to the callback
				callback null, contents
	tarStream.on 'error', ->
		callback "Error while extracting #{filename}", null

# Updates package list.
readPackages = (callback) ->

	if auth.packages?
		for _package, version of auth.packages
			_package = _package.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1").replace(/\\\*/, '.*')
			return true if (RegExp("^#{_package}$", 'i').test testPackage) and version testVersion
	
	# check user
	if auth.users?[username]?.packages?
		for _package, version of auth.users[username].packages
			_package = _package.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1").replace(/\\\*/, '.*')
			return true if (RegExp("^#{_package}$", 'i').test testPackage) and version testVersion
		# check user groups
		for group in auth.users[username].groups
			if auth.groups?[group]?
				for _package, version of auth.groups[group]
					_package = _package.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1").replace(/\\\*/, '.*')
					return true if (RegExp("^#{_package}$", 'i').test testPackage) and version testVersion
	false

# extracts and parses the package.xml of the archive given as `filename`
