////////////////////////////////////////////////////////////////////////////
+ void RepoManager::cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv )
+ {
+ MIL << "Going to clean up garbage in cache dirs" << endl;
+
+ ProgressData progress(300);
+ progress.sendTo(progressrcv);
+ progress.toMin();
+
+ std::list<Pathname> cachedirs;
+ cachedirs.push_back(_pimpl->options.repoRawCachePath);
+ cachedirs.push_back(_pimpl->options.repoPackagesCachePath);
+ cachedirs.push_back(_pimpl->options.repoSolvCachePath);
+
+ for_( dir, cachedirs.begin(), cachedirs.end() )
+ {
+ if ( PathInfo(*dir).isExist() )
+ {
+ std::list<Pathname> entries;
+ if ( filesystem::readdir( entries, *dir, false ) != 0 )
+ // TranslatorExplanation '%s' is a pathname
+ ZYPP_THROW(Exception(str::form(_("Failed to read directory '%s'"), dir->c_str())));
+
+ unsigned sdircount = entries.size();
+ unsigned sdircurrent = 1;
+ for_( subdir, entries.begin(), entries.end() )
+ {
+ // if it does not belong known repo, make it disappear
+ bool found = false;
+ for_( r, repoBegin(), repoEnd() )
+ if ( subdir->basename() == r->escaped_alias() )
+ { found = true; break; }
+
+ if ( ! found )
+ filesystem::recursive_rmdir( *subdir );
+
+ progress.set( progress.val() + sdircurrent * 100 / sdircount );
+ ++sdircurrent;
+ }
+ }
+ else
+ progress.set( progress.val() + 100 );
+ }
+ progress.toMax();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+
void RepoManager::cleanCache( const RepoInfo &info,
const ProgressData::ReceiverFnc & progressrcv )
{
progress.sendTo(progressrcv);
progress.toMin();
+ MIL << "Removing raw metadata cache for " << info.alias() << endl;
filesystem::recursive_rmdir(solv_path_for_repoinfo(_pimpl->options, info));
progress.toMax();
const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
+ * Remove any subdirectories of cache directories which no longer belong
+ * to any of known repositories.
+ *
+ * These can be temporary directories left by interrupted refresh,
+ * or dirs left after changing .repo files outside of libzypp.
+ */
+ void cleanCacheDirGarbage( const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
+
+ /**
* \short Probe repo metadata type.
*
* The location to probe consists of the base \a url (you may think of it as