Commit bf9c6f25 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Folder: Add a setFileSystem factory method

This is needed to instantiate a device in order to get its mountpoint
parent f202d00c
......@@ -34,7 +34,9 @@ namespace policy
unsigned int Folder::* const FolderTable::PrimaryKey = &Folder::m_id;
}
Folder::Folder(DBConnection dbConnection, sqlite::Row& row )
std::shared_ptr<factory::IFileSystem> Folder::FsFactory;
Folder::Folder( DBConnection dbConnection, sqlite::Row& row )
: m_dbConection( dbConnection )
{
row >> m_id
......@@ -101,6 +103,11 @@ bool Folder::blacklist( DBConnection connection, const std::string& path )
return sqlite::Tools::insert( connection, req, path, nullptr, true ) != 0;
}
void Folder::setFileSystemFactory( std::shared_ptr<factory::IFileSystem> fsFactory )
{
FsFactory = fsFactory;
}
std::shared_ptr<Folder> Folder::fromPath( DBConnection conn, const std::string& path )
{
const std::string req = "SELECT * FROM " + policy::FolderTable::Name + " WHERE path = ? AND is_blacklisted IS NULL";
......
......@@ -23,6 +23,7 @@
#pragma once
#include "database/DatabaseHelpers.h"
#include "factory/IFileSystem.h"
#include <sqlite3.h>
......@@ -54,6 +55,12 @@ public:
static bool createTable( DBConnection connection );
static std::shared_ptr<Folder> create(DBConnection connection, const std::string& path, time_t lastModificationDate, unsigned int parentId, Device& device );
static bool blacklist( DBConnection connection, const std::string& path );
///
/// \brief setFileSystemFactory Sets a file system factory to be used when building IDevices
/// This is assumed to be called once, before any discovery/reloading process is launched.
/// \param fsFactory The factory to be used
///
static void setFileSystemFactory( std::shared_ptr<factory::IFileSystem> fsFactory );
static std::shared_ptr<Folder> fromPath( DBConnection conn, const std::string& path );
......
......@@ -114,6 +114,7 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
{
if ( m_fsFactory == nullptr )
m_fsFactory.reset( new factory::FileSystemFactory );
Folder::setFileSystemFactory( m_fsFactory );
m_snapshotPath = snapshotPath;
m_callback = mlCallback;
m_dbConnection.reset( new SqliteConnection( dbPath ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment