From f9a64d24bfe8ff262bbf32fd75615153f697f774 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 27 Oct 2016 19:45:36 +0200 Subject: [PATCH] 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. --- src/storage/CompositeStorage.cxx | 18 ++++++------------ src/storage/CompositeStorage.hxx | 1 - 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/storage/CompositeStorage.cxx b/src/storage/CompositeStorage.cxx index ce9c1e8b1..9e0a45f42 100644 --- a/src/storage/CompositeStorage.cxx +++ b/src/storage/CompositeStorage.cxx @@ -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); } diff --git a/src/storage/CompositeStorage.hxx b/src/storage/CompositeStorage.hxx index 3ae53738d..afe60e22e 100644 --- a/src/storage/CompositeStorage.hxx +++ b/src/storage/CompositeStorage.hxx @@ -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;