Commit 672e0ad1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

File: Remove Type::Entire

This denotes that this file would know about other files (actually, the
lack of any other file), which isn't planned, expected, and would
require us to change the file type in case we add another MRL to a media
parent 1beb911f
......@@ -34,13 +34,7 @@ public:
{
/// Unknown type, so far
Unknown,
/// The file is the entire media.
/// This implies there's only a single file for a media
Entire,
/// The main file of a media.
/// This implies the media has other parts, for instance, the "Main"
/// part is the video plus some default soundtrack, and there is
/// another file of type "soundtrack"
Main,
/// A part of a media (for instance, the first half of a movie)
Part,
......
......@@ -400,14 +400,14 @@ std::vector<MediaPtr> Media::listAll( MediaLibraryPtr ml, IMedia::Type type, Sor
req = "SELECT m.* FROM " + policy::MediaTable::Name + " m INNER JOIN "
+ policy::FileTable::Name + " f ON m.id_media = f.media_id"
" WHERE m.type = ?"
" AND ( f.type = ? OR f.type = ? )";
" AND f.type = ?";
if ( sort == SortingCriteria::LastModificationDate )
req += " ORDER BY f.last_modification_date";
else
req += " ORDER BY f.size";
if ( desc == true )
req += " DESC";
return fetchAll<IMedia>( ml, req, type, File::Type::Entire, File::Type::Main );
return fetchAll<IMedia>( ml, req, type, File::Type::Main );
}
req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE type = ? AND is_present = 1 ORDER BY ";
switch ( sort )
......
......@@ -347,7 +347,7 @@ std::shared_ptr<Media> MediaLibrary::addFile( const fs::IFile& fileFs, Folder& p
return nullptr;
}
// For now, assume all media are made of a single file
auto file = mptr->addFile( fileFs, parentFolder, parentFolderFs, File::Type::Entire );
auto file = mptr->addFile( fileFs, parentFolder, parentFolderFs, File::Type::Main );
if ( file == nullptr )
{
LOG_ERROR( "Failed to add file ", fileFs.fullPath(), " to media #", mptr->id() );
......
......@@ -50,7 +50,7 @@ TEST_F( Files, Create )
ASSERT_EQ( "media.mkv", f->mrl() );
ASSERT_NE( 0u, f->lastModificationDate() );
ASSERT_NE( 0u, f->size() );
ASSERT_EQ( File::Type::Entire, f->type() );
ASSERT_EQ( File::Type::Main, f->type() );
}
TEST_F( Files, Remove )
......
......@@ -61,7 +61,7 @@ TEST_F( Medias, Create )
ASSERT_EQ( 1u, files.size() );
auto f = files[0];
ASSERT_FALSE( f->isExternal() );
ASSERT_EQ( File::Type::Entire, f->type() );
ASSERT_EQ( File::Type::Main, f->type() );
}
TEST_F( Medias, Fetch )
......
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