summaryrefslogtreecommitdiff
path: root/apt-pkg/cachefile.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-02-11 22:36:03 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-02-11 22:36:03 +0100
commitfbb2c7e04dd3155983560e0b01a71fd8f62f0b1b (patch)
tree638b2a0477372f5b36690dbc32da19488ed34ee0 /apt-pkg/cachefile.cc
parentf40db111e15e0d7bed3a6432d96c17553ee6f68e (diff)
* apt-pkg/cachefile.cc:
- clean up lost atomic cachefiles with 'clean' (Closes: #650513)
Diffstat (limited to 'apt-pkg/cachefile.cc')
-rw-r--r--apt-pkg/cachefile.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 1b8d91a44..e425c940d 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -178,6 +178,40 @@ void pkgCacheFile::RemoveCaches()
unlink(pkgcache.c_str());
if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true)
unlink(srcpkgcache.c_str());
+ if (pkgcache.empty() == false)
+ {
+ std::string cachedir = flNotFile(pkgcache);
+ std::string cachefile = flNotDir(pkgcache);
+ if (cachedir.empty() != true && cachefile.empty() != true)
+ {
+ cachefile.append(".");
+ std::vector<std::string> caches = GetListOfFilesInDir(cachedir, false);
+ for (std::vector<std::string>::const_iterator file = caches.begin(); file != caches.end(); ++file)
+ {
+ std::string nuke = flNotDir(*file);
+ if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0)
+ continue;
+ unlink(file->c_str());
+ }
+ }
+ }
+
+ if (srcpkgcache.empty() == true)
+ return;
+
+ std::string cachedir = flNotFile(srcpkgcache);
+ std::string cachefile = flNotDir(srcpkgcache);
+ if (cachedir.empty() == true || cachefile.empty() == true)
+ return;
+ cachefile.append(".");
+ std::vector<std::string> caches = GetListOfFilesInDir(cachedir, false);
+ for (std::vector<std::string>::const_iterator file = caches.begin(); file != caches.end(); ++file)
+ {
+ std::string nuke = flNotDir(*file);
+ if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0)
+ continue;
+ unlink(file->c_str());
+ }
}
/*}}}*/
// CacheFile::Close - close the cache files /*{{{*/