storage/Composite: eliminate the second FindStorage() overload

It was used in a wrong way, which did not deal with errors
consistently.  And if that's wrong, there is no need for FindStorage()
at all - let's remove it and the confusion around it.
This commit is contained in:
Max Kellermann 2016-10-27 19:45:36 +02:00
parent e1a8dcfcc8
commit f9a64d24bf
2 changed files with 6 additions and 13 deletions

View File

@ -265,22 +265,13 @@ CompositeStorage::FindStorage(const char *uri) const
return result;
}
CompositeStorage::FindResult
CompositeStorage::FindStorage(const char *uri, Error &error) const
{
auto result = FindStorage(uri);
if (result.directory == nullptr)
error.Set(composite_domain, "No such directory");
return result;
}
bool
CompositeStorage::GetInfo(const char *uri, bool follow, FileInfo &info,
Error &error)
{
const ScopeLock protect(mutex);
auto f = FindStorage(uri, error);
auto f = FindStorage(uri);
if (f.directory->storage != nullptr &&
f.directory->storage->GetInfo(f.uri, follow, info, error))
return true;
@ -295,6 +286,7 @@ CompositeStorage::GetInfo(const char *uri, bool follow, FileInfo &info,
return true;
}
error.Set(composite_domain, "No such directory");
return false;
}
@ -304,13 +296,15 @@ CompositeStorage::OpenDirectory(const char *uri,
{
const ScopeLock protect(mutex);
auto f = FindStorage(uri, error);
auto f = FindStorage(uri);
const Directory *directory = f.directory->Find(f.uri);
if (directory == nullptr || directory->children.empty()) {
/* no virtual directories here */
if (f.directory->storage == nullptr)
if (f.directory->storage == nullptr) {
error.Set(composite_domain, "No such directory");
return nullptr;
}
return f.directory->storage->OpenDirectory(f.uri, error);
}

View File

@ -165,7 +165,6 @@ private:
*/
gcc_pure
FindResult FindStorage(const char *uri) const;
FindResult FindStorage(const char *uri, Error &error) const;
const char *MapToRelativeUTF8(const Directory &directory,
const char *uri) const;