StoragePlugin: pass EventLoop to constructor
This commit is contained in:
@@ -31,9 +31,10 @@
|
||||
#include <assert.h>
|
||||
|
||||
static Storage *
|
||||
CreateConfiguredStorageUri(const char *uri, Error &error)
|
||||
CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri,
|
||||
Error &error)
|
||||
{
|
||||
Storage *storage = CreateStorageURI(uri, error);
|
||||
Storage *storage = CreateStorageURI(event_loop, uri, error);
|
||||
if (storage == nullptr && !error.IsDefined())
|
||||
error.Format(config_domain,
|
||||
"Unrecognized storage URI: %s", uri);
|
||||
@@ -63,13 +64,13 @@ CreateConfiguredStorageLocal(Error &error)
|
||||
}
|
||||
|
||||
Storage *
|
||||
CreateConfiguredStorage(Error &error)
|
||||
CreateConfiguredStorage(EventLoop &event_loop, Error &error)
|
||||
{
|
||||
assert(!error.IsDefined());
|
||||
|
||||
auto uri = config_get_string(CONF_MUSIC_DIR, nullptr);
|
||||
if (uri != nullptr && uri_has_scheme(uri))
|
||||
return CreateConfiguredStorageUri(uri, error);
|
||||
return CreateConfiguredStorageUri(event_loop, uri, error);
|
||||
|
||||
return CreateConfiguredStorageLocal(error);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
class Error;
|
||||
class Storage;
|
||||
class EventLoop;
|
||||
|
||||
/**
|
||||
* Read storage configuration settings and create a #Storage instance
|
||||
@@ -32,7 +33,7 @@ class Storage;
|
||||
* (no #Error set in that case).
|
||||
*/
|
||||
Storage *
|
||||
CreateConfiguredStorage(Error &error);
|
||||
CreateConfiguredStorage(EventLoop &event_loop, Error &error);
|
||||
|
||||
/**
|
||||
* Returns true if there is configuration for a #Storage instance.
|
||||
|
||||
@@ -52,7 +52,7 @@ GetStoragePluginByName(const char *name)
|
||||
}
|
||||
|
||||
Storage *
|
||||
CreateStorageURI(const char *uri, Error &error)
|
||||
CreateStorageURI(EventLoop &event_loop, const char *uri, Error &error)
|
||||
{
|
||||
assert(!error.IsDefined());
|
||||
|
||||
@@ -62,7 +62,7 @@ CreateStorageURI(const char *uri, Error &error)
|
||||
if (plugin.create_uri == nullptr)
|
||||
continue;
|
||||
|
||||
Storage *storage = plugin.create_uri(uri, error);
|
||||
Storage *storage = plugin.create_uri(event_loop, uri, error);
|
||||
if (storage != nullptr || error.IsDefined())
|
||||
return storage;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
struct StoragePlugin;
|
||||
class Storage;
|
||||
class Error;
|
||||
class EventLoop;
|
||||
|
||||
/**
|
||||
* nullptr terminated list of all storage plugins which were enabled at
|
||||
@@ -39,6 +40,6 @@ GetStoragePluginByName(const char *name);
|
||||
|
||||
gcc_nonnull_all gcc_malloc
|
||||
Storage *
|
||||
CreateStorageURI(const char *uri, Error &error);
|
||||
CreateStorageURI(EventLoop &event_loop, const char *uri, Error &error);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
|
||||
class Error;
|
||||
class Storage;
|
||||
class EventLoop;
|
||||
|
||||
struct StoragePlugin {
|
||||
const char *name;
|
||||
|
||||
Storage *(*create_uri)(const char *uri, Error &error);
|
||||
Storage *(*create_uri)(EventLoop &event_loop, const char *uri,
|
||||
Error &error);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -203,7 +203,8 @@ NfsStorage::OpenDirectory(const char *uri_utf8, Error &error)
|
||||
}
|
||||
|
||||
static Storage *
|
||||
CreateNfsStorageURI(const char *base, Error &error)
|
||||
CreateNfsStorageURI(gcc_unused EventLoop &event_loop, const char *base,
|
||||
Error &error)
|
||||
{
|
||||
if (memcmp(base, "nfs://", 6) != 0)
|
||||
return nullptr;
|
||||
|
||||
@@ -180,7 +180,8 @@ SmbclientDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info,
|
||||
}
|
||||
|
||||
static Storage *
|
||||
CreateSmbclientStorageURI(const char *base, Error &error)
|
||||
CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base,
|
||||
Error &error)
|
||||
{
|
||||
if (memcmp(base, "smb://", 6) != 0)
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user