aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-05 14:42:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-05 14:42:28 +0000
commita6c3a1e4729b1266db52ddcbbecbadcafef34455 (patch)
tree82051e094b49e4606a914245816562e6ee98f7b1
parent99b51a23b3f8e261c97d03feb186eae8aa703acc (diff)
downloadpaludis-a6c3a1e4729b1266db52ddcbbecbadcafef34455.tar.gz
paludis-a6c3a1e4729b1266db52ddcbbecbadcafef34455.tar.xz
Add the repository name to names cache locations. Fixes: ticket:78.
-rw-r--r--paludis/repository_name_cache.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/paludis/repository_name_cache.cc b/paludis/repository_name_cache.cc
index 4883e03..73a7158 100644
--- a/paludis/repository_name_cache.cc
+++ b/paludis/repository_name_cache.cc
@@ -43,7 +43,7 @@ namespace paludis
mutable bool checked_name_cache_map;
Implementation(const FSEntry & l, const Repository * const r) :
- location(l),
+ location(l / stringify(r->name())),
repo(r),
checked_name_cache_map(false)
{
@@ -70,6 +70,8 @@ RepositoryNameCache::category_names_containing_package(const PackageNamePart & p
if (! usable())
return std::tr1::shared_ptr<const CategoryNamePartCollection>();
+ Context context("When using name cache at '" + stringify(_imp->location) + "':");
+
std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
NameCacheMap::iterator r(_imp->name_cache_map.find(p));
@@ -79,10 +81,9 @@ RepositoryNameCache::category_names_containing_package(const PackageNamePart & p
if (! _imp->checked_name_cache_map)
{
- FSEntry vv(_imp->location / "_VERSION_");
- if (vv.exists())
+ if (_imp->location.is_directory() && (_imp->location / "_VERSION_").exists())
{
- std::ifstream vvf(stringify(vv).c_str());
+ std::ifstream vvf(stringify(_imp->location / "_VERSION_").c_str());
std::string line;
std::getline(vvf, line);
if (line != "paludis-2")
@@ -104,6 +105,17 @@ RepositoryNameCache::category_names_containing_package(const PackageNamePart & p
}
_imp->checked_name_cache_map = true;
}
+ else if ((_imp->location.dirname() / "_VERSION_").exists())
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Names cache for '" + stringify(_imp->repo->name())
+ + "' does not exist at '" + stringify(_imp->location) + "', but a names cache exists at '" +
+ stringify(_imp->location.dirname()) + "'. This was probably generated by a Paludis version "
+ "older than 0.18.0. The names cache now automatically appends the repository name to the "
+ "directory. You probably want to manually remove '" + stringify(_imp->location.dirname()) +
+ "' and then regenerate the cache.");
+ _usable = false;
+ return std::tr1::shared_ptr<const CategoryNamePartCollection>();
+ }
else
{
Log::get_instance()->message(ll_warning, lc_context, "Names cache for '" + stringify(_imp->repo->name())
@@ -145,6 +157,8 @@ RepositoryNameCache::regenerate_cache() const
FSEntry(*i).unlink();
_imp->location.dirname().mkdir();
+ if (_imp->location.exists() && ! _imp->location.is_directory())
+ FSEntry(_imp->location).unlink();
FSEntry(_imp->location).mkdir();
MakeHashedMap<std::string, std::string>::Type m;
@@ -182,3 +196,4 @@ RepositoryNameCache::regenerate_cache() const
Log::get_instance()->message(ll_warning, lc_context, "Cannot write to '"
+ stringify(_imp->location) + "'");
}
+