From 5c1dbf8c6fc9d9b38e80b03833eebd0a3a289e67 Mon Sep 17 00:00:00 2001 From: Dominik Heidler Date: Fri, 6 May 2011 13:21:20 +0200 Subject: [PATCH] delete old metadata temp directories --- zypp/RepoManager.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index bec8011..8d704fe 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -554,6 +554,8 @@ namespace zypp if ( PathInfo(options.knownReposPath).isExist() ) { RepoInfoList repol = repositories_in_dir(options.knownReposPath); + std::list repo_esc_aliases; + std::list entries; for ( RepoInfoList::iterator it = repol.begin(); it != repol.end(); ++it ) @@ -567,6 +569,20 @@ namespace zypp (*it).setPackagesPath(packages_path); repos.insert(*it); + repo_esc_aliases.push_back(it->escaped_alias()); + } + + // delete metadata folders without corresponding repo (e.g. old tmp directories) + if ( filesystem::readdir( entries, options.repoRawCachePath, false ) == 0 ) + { + std::set oldfiles; + repo_esc_aliases.sort(); + entries.sort(); + set_difference(entries.begin(), entries.end(), repo_esc_aliases.begin(), repo_esc_aliases.end(), std::inserter(oldfiles, oldfiles.end())); + for_(it, oldfiles.begin(), oldfiles.end()) + { + filesystem::recursive_rmdir(options.repoRawCachePath / *it); + } } } -- 2.7.4