From 83f7610dd14b2fbfdbc2bcd1cda269d055e6148c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Feb 2019 15:07:40 +0100 Subject: [PATCH] storage/udisks2: move empty string check out of the fallback block in MapUTF8() Even if the LocalStorage is available, return the "udisks://" URI when the MapUTF8() parameter is an empty string. This fixes the mount URI in the state file. --- src/storage/plugins/UdisksStorage.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx index 07ba6f45f..60f1e27e0 100644 --- a/src/storage/plugins/UdisksStorage.cxx +++ b/src/storage/plugins/UdisksStorage.cxx @@ -331,16 +331,18 @@ UdisksStorage::MapUTF8(const char *uri_utf8) const noexcept { assert(uri_utf8 != nullptr); + if (StringIsEmpty(uri_utf8)) + /* kludge for a special case: return the "udisks://" + URI if the parameter is an empty string to fix the + mount URIs in the state file */ + return base_uri; + try { const_cast(this)->MountWait(); return mounted_storage->MapUTF8(uri_utf8); } catch (...) { /* fallback - not usable but the best we can do */ - - if (StringIsEmpty(uri_utf8)) - return base_uri; - return PathTraitsUTF8::Build(base_uri.c_str(), uri_utf8); } }