]> git.saurik.com Git - apt.git/blobdiff - methods/ftp.cc
Add a more or less useful README file for everything related to MultiArch
[apt.git] / methods / ftp.cc
index f595e0ca4c0c41ae904bce696a1ae644faac12e9..c91600ad5388f7cc675922ce731e37ad43faf59e 100644 (file)
@@ -112,23 +112,28 @@ bool FTPConn::Open(pkgAcqMethod *Owner)
    Close();
    
    // Determine the proxy setting
-   if (getenv("ftp_proxy") == 0)
+   string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
+   if (!SpecificProxy.empty())
    {
-      string DefProxy = _config->Find("Acquire::ftp::Proxy");
-      string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
-      if (SpecificProxy.empty() == false)
-      {
-        if (SpecificProxy == "DIRECT")
-           Proxy = "";
-        else
-           Proxy = SpecificProxy;
-      }   
-      else
-        Proxy = DefProxy;
+          if (SpecificProxy == "DIRECT")
+                  Proxy = "";
+          else
+                  Proxy = SpecificProxy;
    }
    else
-      Proxy = getenv("ftp_proxy");
-   
+   {
+          string DefProxy = _config->Find("Acquire::ftp::Proxy");
+          if (!DefProxy.empty())
+          {
+                  Proxy = DefProxy;
+          }
+          else
+          {
+                  char* result = getenv("ftp_proxy");
+                  Proxy = result ? result : "";
+          }
+   }
+
    // Parse no_proxy, a , separated list of domains
    if (getenv("no_proxy") != 0)
    {
@@ -1055,9 +1060,12 @@ bool FtpMethod::Fetch(FetchItem *Itm)
         UBuf.modtime = FailTime;
         utime(FailFile.c_str(),&UBuf);
         
-        // If the file is missing we hard fail otherwise transient fail
-        if (Missing == true)
+        // If the file is missing we hard fail and delete the destfile
+        // otherwise transient fail
+        if (Missing == true) {
+           unlink(FailFile.c_str());
            return false;
+        }
         Fail(true);
         return true;
       }
@@ -1098,7 +1106,7 @@ int main(int argc,const char *argv[])
         char S[300];
         snprintf(S,sizeof(S),"http_proxy=%s",getenv("ftp_proxy"));
         putenv(S);
-        putenv("no_proxy=");
+        putenv((char *)"no_proxy=");
         
         // Run the http method
         string Path = flNotFile(argv[0]) + "http";