retry without partial data after a 416 response
[ntk/apt.git] / methods / mirror.cc
index a3e60ab..8543663 100644 (file)
@@ -8,6 +8,8 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/acquire-method.h>
@@ -16,7 +18,8 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/sourcelist.h>
-
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/metaindex.h>
 
 #include <algorithm>
 #include <fstream>
@@ -34,7 +37,7 @@ using namespace std;
 
 #include "mirror.h"
 #include "http.h"
-#include "apti18n.h"
+#include <apti18n.h>
                                                                        /*}}}*/
 
 /* Done:
@@ -121,9 +124,10 @@ bool MirrorMethod::Clean(string Dir)
       if (I == list.end())
         unlink(Dir->d_name);
    };
-   
-   chdir(StartDir.c_str());
+
    closedir(D);
+   if (chdir(StartDir.c_str()) != 0)
+      return _error->Errno("chdir",_("Unable to change to %s"),StartDir.c_str());
    return true;   
 }
 
@@ -144,9 +148,9 @@ bool MirrorMethod::DownloadMirrorFile(string mirror_uri_str)
    // append all architectures
    std::vector<std::string> vec = APT::Configuration::getArchitectures();
    for (std::vector<std::string>::const_iterator I = vec.begin();
-        I != vec.end(); I++)
+        I != vec.end(); ++I)
       if (I == vec.begin())
-         fetch += "?arch" + (*I);
+         fetch += "?arch=" + (*I);
       else
          fetch += "&arch=" + (*I);
 
@@ -307,6 +311,9 @@ bool MirrorMethod::InitMirrors()
 
       AllMirrors.push_back(s);
    }
+   if (AllMirrors.empty()) {
+       return _error->Error(_("No entry found in mirror file '%s'"), MirrorFile.c_str());
+   }
    Mirror = AllMirrors[0];
    UsedMirror = Mirror;
    return true;