Browse Source

minor proxy-related fixes

Nicolas Cannasse 17 years ago
parent
commit
a321da9e1f
2 changed files with 15 additions and 14 deletions
  1. 2 1
      std/neko/net/ProxyDetect.hx
  2. 13 13
      std/tools/haxelib/Main.hx

+ 2 - 1
std/neko/net/ProxyDetect.hx

@@ -96,7 +96,8 @@ class ProxyDetect {
 			// might fail without appropriate rights
 			return null;
 		}
-		var content = neko.io.File.getContent(temp);
+		// it's possible that if registry access was disabled the proxy file is not created
+		var content = try neko.io.File.getContent(temp) catch( e : Dynamic ) return null;
 		neko.FileSystem.deleteFile(temp);
 		// turn 16-bit string into 8-bit one
 		var b = new StringBuf();

+ 13 - 13
std/tools/haxelib/Main.hx

@@ -101,7 +101,7 @@ class Main {
 
 	var argcur : Int;
 	var args : Array<String>;
-	var commands : List<{ name : String, doc : String, f : Void -> Void }>;
+	var commands : List<{ name : String, doc : String, f : Void -> Void, net : Bool }>;
 	var siteUrl : String;
 	var site : SiteProxy;
 
@@ -109,21 +109,21 @@ class Main {
 		args = neko.Sys.args();
 		commands = new List();
 		addCommand("install",install,"install a given project");
-		addCommand("list",list,"list all installed projects");
+		addCommand("list",list,"list all installed projects",false);
 		addCommand("upgrade",upgrade,"upgrade all installed projects");
-		addCommand("remove",remove,"remove a given project/version");
-		addCommand("set",set,"set the current version for a project");
+		addCommand("remove",remove,"remove a given project/version",false);
+		addCommand("set",set,"set the current version for a project",false);
 		addCommand("search",search,"list projects matching a word");
 		addCommand("info",info,"list informations on a given project");
 		addCommand("user",user,"list informations on a given user");
 		addCommand("register",register,"register a new user");
 		addCommand("submit",submit,"submit or update a project package");
-		addCommand("setup",setup,"set the haxelib repository path");
-		addCommand("config",config,"print the repository path");
-		addCommand("path",path,"give paths to libraries");
-		addCommand("run",run,"run the specified project with parameters");
-		addCommand("test",test,"install the specified package localy");
-		addCommand("dev",dev,"set the development directory for a given project");
+		addCommand("setup",setup,"set the haxelib repository path",false);
+		addCommand("config",config,"print the repository path",false);
+		addCommand("path",path,"give paths to libraries",false);
+		addCommand("run",run,"run the specified project with parameters",false);
+		addCommand("test",test,"install the specified package localy",false);
+		addCommand("dev",dev,"set the development directory for a given project",false);
 		siteUrl = "http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.dir;
 		site = new SiteProxy(haxe.remoting.HttpConnection.urlConnect(siteUrl+SERVER.url).api);
 	}
@@ -161,8 +161,8 @@ class Main {
 		return null;
 	}
 
-	function addCommand( name, f, doc ) {
-		commands.add({ name : name, doc : doc, f : f });
+	function addCommand( name, f, doc, ?net ) {
+		commands.add({ name : name, doc : doc, f : f, net : net });
 	}
 
 	function usage() {
@@ -189,6 +189,7 @@ class Main {
 		for( c in commands )
 			if( c.name == cmd ) {
 				try {
+					if( c.net ) haxe.Http.PROXY = neko.net.ProxyDetect.detect();
 					c.f();
 				} catch( e : Dynamic ) {
 					if( e == "std@host_resolve" ) {
@@ -724,7 +725,6 @@ class Main {
 	}
 
 	static function main() {
-		haxe.Http.PROXY = neko.net.ProxyDetect.detect();
 		new Main().process();
 	}