Commit 30cfbdce authored by Alexandre Fernandez's avatar Alexandre Fernandez Committed by Hugo Beauzée-Luyssen

File: Rename static method to create File from Media

Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent e7cd5d7f
......@@ -218,7 +218,8 @@ bool File::createTable( DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, folderIndexReq );
}
std::shared_ptr<File> File::create( MediaLibraryPtr ml, int64_t mediaId, Type type, const fs::IFile& fileFs, int64_t folderId, bool isRemovable )
std::shared_ptr<File> File::createFromMedia( MediaLibraryPtr ml, int64_t mediaId, Type type, const fs::IFile& fileFs,
int64_t folderId, bool isRemovable )
{
auto self = std::make_shared<File>( ml, mediaId, type, fileFs, folderId, isRemovable );
static const std::string req = "INSERT INTO " + policy::FileTable::Name +
......@@ -231,7 +232,8 @@ std::shared_ptr<File> File::create( MediaLibraryPtr ml, int64_t mediaId, Type ty
return self;
}
std::shared_ptr<File> File::create( MediaLibraryPtr ml, int64_t mediaId, IFile::Type type, const std::string& mrl )
std::shared_ptr<File> File::createFromMedia( MediaLibraryPtr ml, int64_t mediaId, IFile::Type type,
const std::string& mrl )
{
// Sqlite won't ensure uniqueness for (folder_id, mrl) when folder_id is null, so we have to ensure
// of it ourselves
......
......@@ -87,9 +87,10 @@ public:
int64_t folderId();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<File> create( MediaLibraryPtr ml, int64_t mediaId, Type type,
const fs::IFile& file, int64_t folderId, bool isRemovable );
static std::shared_ptr<File> create( MediaLibraryPtr ml, int64_t mediaId, Type type, const std::string& mrl );
static std::shared_ptr<File> createFromMedia( MediaLibraryPtr ml, int64_t mediaId, Type type,
const fs::IFile& file, int64_t folderId, bool isRemovable );
static std::shared_ptr<File> createFromMedia( MediaLibraryPtr ml, int64_t mediaId, Type type,
const std::string& mrl );
/**
* @brief fromPath Attempts to fetch a file using its mrl
* This will only work if the file was stored on a non removable device
......
......@@ -376,7 +376,8 @@ bool Media::save()
std::shared_ptr<File> Media::addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs, IFile::Type type )
{
auto file = File::create( m_ml, m_id, type, fileFs, parentFolder.id(), parentFolderFs.device()->isRemovable() );
auto file = File::createFromMedia( m_ml, m_id, type, fileFs, parentFolder.id(),
parentFolderFs.device()->isRemovable());
if ( file == nullptr )
return nullptr;
auto lock = m_files.lock();
......@@ -390,7 +391,7 @@ FilePtr Media::addExternalMrl( const std::string& mrl , IFile::Type type )
FilePtr file;
try
{
file = File::create( m_ml, m_id, type, mrl );
file = File::createFromMedia( m_ml, m_id, type, mrl );
}
catch ( const sqlite::errors::Generic& ex )
{
......
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