summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2007-01-08 12:10:05 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2007-01-08 12:10:05 +0100
commit0c312e0ed24fed69412c181634dd4515e9b1d46f (patch)
tree69ed6e582d72fab4319d0497c4c3b0bc2e64dc3b
parent70288656715d2fe4c2c33598124ae48f7bca9cdf (diff)
* implemented proper mirror list cleanup
-rw-r--r--methods/mirror.cc39
-rw-r--r--po/apt-all.pot4
2 files changed, 23 insertions, 20 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc
index 425a2f7f5..00f7b7807 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -14,6 +14,7 @@
#include <apt-pkg/acquire.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/sourcelist.h>
#include <fstream>
#include <iostream>
@@ -71,9 +72,14 @@ bool MirrorMethod::Configuration(string Message)
// clean the mirrors dir based on ttl information
bool MirrorMethod::Clean(string Dir)
{
- // FIXME: it would better to have a global idea of the mirrors
- // in the sources.list and use this instead of this time
- // based approach. currently apt does not support this :/
+ vector<metaIndex *>::const_iterator I;
+
+ if(Debug)
+ clog << "MirrorMethod::Clean(): " << Dir << endl;
+
+ // read sources.list
+ pkgSourceList list;
+ list.ReadMainList();
DIR *D = opendir(Dir.c_str());
if (D == 0)
@@ -94,24 +100,21 @@ bool MirrorMethod::Clean(string Dir)
strcmp(Dir->d_name,".") == 0 ||
strcmp(Dir->d_name,"..") == 0)
continue;
-
- // Del everything not touched for MaxAge days
- time_t t,now,max;
- struct stat buf;
- if(stat(Dir->d_name, &buf) != 0)
+
+ // see if we have that uri
+ for(I=list.begin(); I != list.end(); I++)
{
- cerr << "Can't stat '" << Dir->d_name << "'" << endl;
- continue;
+ string uri = (*I)->GetURI();
+ if(uri.substr(0,strlen("mirror://")) != string("mirror://"))
+ continue;
+ string Marker = _config->Find("Acquire::Mirror::MagicMarker","///");
+ string BaseUri = uri.substr(0,uri.find(Marker));
+ if (URItoFileName(BaseUri) == Dir->d_name)
+ break;
}
- t = std::max(buf.st_mtime, buf.st_ctime);
- now = time(NULL);
- max = 24*60*60*_config->FindI("Acquire::Mirror::MaxAge",90);
- if(t + max < now)
- {
- if(Debug)
- clog << "Mirror file is older than MaxAge days, deleting" << endl;
+ // nothing found, nuke it
+ if (I == list.end())
unlink(Dir->d_name);
- }
};
chdir(StartDir.c_str());
diff --git a/po/apt-all.pot b/po/apt-all.pot
index d1ce72503..52fadb81c 100644
--- a/po/apt-all.pot
+++ b/po/apt-all.pot
@@ -1330,7 +1330,7 @@ msgstr ""
#: apt-inst/extract.cc:467 apt-pkg/contrib/configuration.cc:750
#: apt-pkg/contrib/cdromutl.cc:153 apt-pkg/sourcelist.cc:324
-#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:76
+#: apt-pkg/acquire.cc:421 apt-pkg/clean.cc:38 methods/mirror.cc:86
#, c-format
msgid "Unable to read %s"
msgstr ""
@@ -1956,7 +1956,7 @@ msgid "Unable to stat the mount point %s"
msgstr ""
#: apt-pkg/contrib/cdromutl.cc:149 apt-pkg/acquire.cc:427 apt-pkg/clean.cc:44
-#: methods/mirror.cc:82
+#: methods/mirror.cc:92
#, c-format
msgid "Unable to change to %s"
msgstr ""