Commit 694e9e7f authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

When a file/folder is not removable, simply store it's full length path

Instead of re-computing it dynamically while it's never going to change
parent 126e1b73
......@@ -48,16 +48,18 @@ Folder::Folder( DBConnection dbConnection, sqlite::Row& row )
>> m_parent
>> m_isBlacklisted
>> m_deviceId
>> m_isPresent;
>> m_isPresent
>> m_isRemovable;
}
Folder::Folder( const std::string& path, unsigned int parent, unsigned int deviceId )
Folder::Folder( const std::string& path, unsigned int parent, unsigned int deviceId, bool isRemovable )
: m_id( 0 )
, m_path( path )
, m_parent( parent )
, m_isBlacklisted( false )
, m_deviceId( deviceId )
, m_isPresent( true )
, m_isRemovable( isRemovable )
{
}
......@@ -71,6 +73,7 @@ bool Folder::createTable(DBConnection connection)
"is_blacklisted INTEGER,"
"device_id UNSIGNED INTEGER,"
"is_present BOOLEAN NOT NULL DEFAULT 1,"
"is_removable BOOLEAN NOT NULL,"
"FOREIGN KEY (id_parent) REFERENCES " + policy::FolderTable::Name +
"(id_folder) ON DELETE CASCADE,"
"FOREIGN KEY (device_id) REFERENCES " + policy::DeviceTable::Name +
......@@ -88,15 +91,22 @@ bool Folder::createTable(DBConnection connection)
std::shared_ptr<Folder> Folder::create( DBConnection connection, const std::string& fullPath, unsigned int parentId, Device& device, fs::IDevice& deviceFs )
{
auto path = utils::file::removePath( fullPath, deviceFs.mountpoint() );
auto self = std::make_shared<Folder>( path, parentId, device.id() );
std::string path;
if ( device.isRemovable() == true )
path = utils::file::removePath( fullPath, deviceFs.mountpoint() );
else
path = fullPath;
auto self = std::make_shared<Folder>( path, parentId, device.id(), device.isRemovable() );
static const std::string req = "INSERT INTO " + policy::FolderTable::Name +
"(path, id_parent, device_id) VALUES(?, ?, ?)";
if ( insert( connection, self, req, path, sqlite::ForeignKey( parentId ), device.id() ) == false )
"(path, id_parent, device_id, is_removable) VALUES(?, ?, ?, ?)";
if ( insert( connection, self, req, path, sqlite::ForeignKey( parentId ), device.id(), device.isRemovable() ) == false )
return nullptr;
self->m_dbConection = connection;
self->m_deviceMountpoint = deviceFs.mountpoint();
self->m_fullPath = self->m_deviceMountpoint.get() + path;
if ( device.isRemovable() == true )
{
self->m_deviceMountpoint = deviceFs.mountpoint();
self->m_fullPath = self->m_deviceMountpoint.get() + path;
}
return self;
}
......@@ -109,10 +119,14 @@ bool Folder::blacklist( DBConnection connection, const std::string& fullPath )
auto device = Device::fromUuid( connection, deviceFs->uuid() );
if ( device == nullptr )
device = Device::create( connection, deviceFs->uuid(), deviceFs->isRemovable() );
auto path = utils::file::removePath( fullPath, deviceFs->mountpoint() );
std::string path;
if ( deviceFs->isRemovable() == true )
path = utils::file::removePath( fullPath, deviceFs->mountpoint() );
else
path = fullPath;
static const std::string req = "INSERT INTO " + policy::FolderTable::Name +
"(path, id_parent, is_blacklisted, device_id) VALUES(?, ?, ?, ?)";
return sqlite::Tools::insert( connection, req, path, nullptr, true, device->id() ) != 0;
"(path, id_parent, is_blacklisted, device_id, is_removable) VALUES(?, ?, ?, ?, ?)";
return sqlite::Tools::insert( connection, req, path, nullptr, true, device->id(), deviceFs->isRemovable() ) != 0;
}
void Folder::setFileSystemFactory( std::shared_ptr<factory::IFileSystem> fsFactory )
......@@ -131,13 +145,20 @@ std::shared_ptr<Folder> Folder::fromPath( DBConnection conn, const std::string&
LOG_ERROR( "Failed to get device containing an existing folder: ", fullPath );
return nullptr;
}
if ( deviceFs->isRemovable() == false )
{
const std::string req = "SELECT * FROM " + policy::FolderTable::Name + " WHERE path = ? AND is_removable = 0"
" AND is_blacklisted IS NULL";
return fetch( conn, req, fullPath );
}
const std::string req = "SELECT * FROM " + policy::FolderTable::Name + " WHERE path = ? AND device_id = ? "
"AND is_blacklisted IS NULL";
auto device = Device::fromUuid( conn, deviceFs->uuid() );
// We are trying to find a folder. If we don't know the device it's on, we don't know the folder.
if ( device == nullptr )
return nullptr;
auto path = utils::file::removePath( fullPath, deviceFs->mountpoint() );
const std::string req = "SELECT * FROM " + policy::FolderTable::Name + " WHERE path = ? AND device_id = ? "
"AND is_blacklisted IS NULL";
auto folder = fetch( conn, req, path, device->id() );
if ( folder == nullptr )
return nullptr;
......@@ -153,6 +174,9 @@ unsigned int Folder::id() const
const std::string& Folder::path() const
{
if ( m_isRemovable == false )
return m_path;
auto lock = m_deviceMountpoint.lock();
if ( m_deviceMountpoint.isCached() == true )
return m_fullPath;
......
......@@ -54,7 +54,7 @@ class Folder : public DatabaseHelpers<Folder, policy::FolderTable>
{
public:
Folder( DBConnection dbConnection, sqlite::Row& row );
Folder( const std::string& path, unsigned int parent , unsigned int deviceId );
Folder( const std::string& path, unsigned int parent , unsigned int deviceId , bool isRemovable );
static bool createTable( DBConnection connection );
static std::shared_ptr<Folder> create( DBConnection connection, const std::string& path, unsigned int parentId, Device& device, fs::IDevice& deviceFs );
......@@ -90,6 +90,7 @@ private:
bool m_isBlacklisted;
unsigned int m_deviceId;
bool m_isPresent;
bool m_isRemovable;
mutable Cache<std::string> m_deviceMountpoint;
// This contains the full path, including device mountpoint.
......
......@@ -38,11 +38,16 @@
#include "database/SqliteTools.h"
#include "VideoTrack.h"
#include "filesystem/IFile.h"
#include "filesystem/IDevice.h"
#include "filesystem/IDirectory.h"
#include "utils/Filename.h"
const std::string policy::MediaTable::Name = "Media";
const std::string policy::MediaTable::PrimaryKeyColumn = "id_media";
unsigned int Media::* const policy::MediaTable::PrimaryKey = &Media::m_id;
std::shared_ptr<factory::IFileSystem> Media::FsFactory;
Media::Media( DBConnection dbConnection, sqlite::Row& row )
: m_dbConnection( dbConnection )
, m_changed( false )
......@@ -61,16 +66,17 @@ Media::Media( DBConnection dbConnection, sqlite::Row& row )
>> m_snapshot
>> m_isParsed
>> m_title
>> m_isPresent;
>> m_isPresent
>> m_isRemovable;
}
Media::Media( const fs::IFile* file, unsigned int folderId, const std::string& title, Type type )
Media::Media( const fs::IFile* file, unsigned int folderId, const std::string& title, Type type, bool isRemovable )
: m_id( 0 )
, m_type( type )
, m_duration( -1 )
, m_playCount( 0 )
, m_showEpisodeId( 0 )
, m_mrl( file->name() )
, m_mrl( isRemovable == true ? file->name() : file->fullPath() )
, m_movieId( 0 )
, m_folderId( folderId )
, m_lastModificationDate( file->lastModificationDate() )
......@@ -78,18 +84,19 @@ Media::Media( const fs::IFile* file, unsigned int folderId, const std::string& t
, m_isParsed( false )
, m_title( title )
, m_isPresent( true )
, m_isRemovable( isRemovable )
, m_changed( false )
{
}
std::shared_ptr<Media> Media::create( DBConnection dbConnection, Type type, const fs::IFile* file, unsigned int folderId )
std::shared_ptr<Media> Media::create( DBConnection dbConnection, Type type, const fs::IFile* file, unsigned int folderId, bool isRemovable )
{
auto self = std::make_shared<Media>( file, folderId, file->name(), type );
auto self = std::make_shared<Media>( file, folderId, file->name(), type, isRemovable );
static const std::string req = "INSERT INTO " + policy::MediaTable::Name +
"(type, mrl, folder_id, last_modification_date, insertion_date, title) VALUES(?, ?, ?, ?, ?, ?)";
"(type, mrl, folder_id, last_modification_date, insertion_date, title, is_removable) VALUES(?, ?, ?, ?, ?, ?, ?)";
if ( insert( dbConnection, self, req, type, self->m_mrl, sqlite::ForeignKey( folderId ),
self->m_lastModificationDate, self->m_insertionDate, self->m_title) == false )
self->m_lastModificationDate, self->m_insertionDate, self->m_title, isRemovable ) == false )
return nullptr;
self->m_dbConnection = dbConnection;
self->m_fullPath = file->fullPath();
......@@ -178,6 +185,9 @@ void Media::increasePlayCount()
const std::string& Media::mrl() const
{
if ( m_isRemovable == false )
return m_mrl;
auto lock = m_fullPath.lock();
if ( m_fullPath.isCached() )
return m_fullPath;
......@@ -284,6 +294,11 @@ bool Media::isParsed() const
return m_isParsed;
}
void Media::setFileSystemFactory(std::shared_ptr<factory::IFileSystem> fsFactory)
{
FsFactory = fsFactory;
}
void Media::markParsed()
{
if ( m_isParsed == true )
......@@ -341,6 +356,7 @@ bool Media::createTable( DBConnection connection )
"parsed BOOLEAN NOT NULL DEFAULT 0,"
"title TEXT,"
"is_present BOOLEAN NOT NULL DEFAULT 1,"
"is_removable BOOLEAN NOT NULL,"
"FOREIGN KEY (show_episode_id) REFERENCES " + policy::ShowEpisodeTable::Name
+ "(id_episode) ON DELETE CASCADE,"
"FOREIGN KEY (movie_id) REFERENCES " + policy::MovieTable::Name
......@@ -358,6 +374,37 @@ bool Media::createTable( DBConnection connection )
sqlite::Tools::executeRequest( connection, triggerReq );
}
MediaPtr Media::fromPath( DBConnection connection, const std::string& fullPath )
{
auto folderPath = utils::file::directory( fullPath );
auto folderFs = FsFactory->createDirectory( folderPath );
if ( folderFs != nullptr )
{
auto deviceFs = folderFs->device();
if ( deviceFs->isRemovable() == false )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name +
" WHERE mrl = ? AND is_present = 1";
return Media::fetch( connection, req, fullPath );
}
}
auto folder = Folder::fromPath( connection, folderPath );
auto folderId = folder != nullptr ? folder->id() : 0;
if ( folderId != 0 )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name +
" WHERE mrl = ? AND folder_id = ? AND is_present = 1";
auto fileName = utils::file::fileName( fullPath );
return Media::fetch( connection, req, fileName, folderId );
}
else
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name +
" WHERE mrl = ? AND folder_id IS NULL AND is_present = 1";
return Media::fetch( connection, req, fullPath );
}
}
bool Media::addLabel( LabelPtr label )
{
if ( m_id == 0 || label->id() == 0 )
......
......@@ -54,10 +54,12 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
// shall be well-formed, and private constructor would prevent that.
// There might be a way with a user-defined allocator, but we'll see that later...
Media(DBConnection dbConnection , sqlite::Row& row);
Media(const fs::IFile* file, unsigned int folderId, const std::string &title, Type type);
Media( const fs::IFile* file, unsigned int folderId, const std::string &title, Type type, bool isRemovable );
static std::shared_ptr<Media> create(DBConnection dbConnection, Type type, const fs::IFile* file , unsigned int folderId);
static std::shared_ptr<Media> create( DBConnection dbConnection, Type type, const fs::IFile* file , unsigned int folderId, bool isRemovable );
static bool createTable( DBConnection connection );
static MediaPtr fromPath( DBConnection connection, const std::string& fullPath );
static void setFileSystemFactory( std::shared_ptr<factory::IFileSystem> fsFactory );
virtual unsigned int id() const override;
virtual Type type() override;
......@@ -100,6 +102,9 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
void markParsed();
bool isParsed() const;
private:
static std::shared_ptr<factory::IFileSystem> FsFactory;
private:
DBConnection m_dbConnection;
......@@ -119,6 +124,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
bool m_isParsed;
std::string m_title;
bool m_isPresent;
bool m_isRemovable;
// Auto fetched related properties
AlbumTrackPtr m_albumTrack;
......
......@@ -55,6 +55,7 @@
#include "filesystem/IDirectory.h"
#include "filesystem/IFile.h"
#include "filesystem/IDevice.h"
#include "factory/FileSystem.h"
const std::vector<std::string> MediaLibrary::supportedVideoExtensions {
......@@ -114,6 +115,7 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
{
if ( m_fsFactory == nullptr )
m_fsFactory.reset( new factory::FileSystemFactory );
Media::setFileSystemFactory( m_fsFactory );
Folder::setFileSystemFactory( m_fsFactory );
m_snapshotPath = snapshotPath;
m_callback = mlCallback;
......@@ -181,25 +183,10 @@ std::vector<MediaPtr> MediaLibrary::videoFiles()
MediaPtr MediaLibrary::file( const std::string& path )
{
auto folderPath = utils::file::directory( path );
auto folder = Folder::fromPath( m_dbConnection.get(), folderPath );
auto folderId = folder != nullptr ? folder->id() : 0;
if ( folderId != 0 )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name +
" WHERE mrl = ? AND folder_id = ? AND is_present = 1";
auto fileName = utils::file::fileName( path );
return Media::fetch( m_dbConnection.get(), req, fileName, folderId );
}
else
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name +
" WHERE mrl = ? AND folder_id IS NULL AND is_present = 1";
return Media::fetch( m_dbConnection.get(), req, path );
}
return Media::fromPath( m_dbConnection.get(), path );
}
std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* parentFolder )
std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* parentFolder, fs::IDirectory* parentFolderFs )
{
std::unique_ptr<fs::IFile> file;
try
......@@ -232,7 +219,9 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* p
return nullptr;
LOG_INFO( "Adding ", path );
auto fptr = Media::create( m_dbConnection.get(), type, file.get(), parentFolder != nullptr ? parentFolder->id() : 0 );
auto fptr = Media::create( m_dbConnection.get(), type, file.get(),
parentFolder != nullptr ? parentFolder->id() : 0,
parentFolderFs != nullptr ? parentFolderFs->device()->isRemovable() : false );
if ( fptr == nullptr )
{
LOG_ERROR( "Failed to add file ", file->fullPath(), " to the media library" );
......
......@@ -54,7 +54,7 @@ class MediaLibrary : public IMediaLibrary
virtual std::vector<MediaPtr> audioFiles() override;
virtual std::vector<MediaPtr> videoFiles() override;
MediaPtr file( const std::string& path );
std::shared_ptr<Media> addFile(const std::string& path, Folder* parentFolder);
std::shared_ptr<Media> addFile(const std::string& path, Folder* parentFolder, fs::IDirectory* parentFolderFs);
virtual bool deleteFile(const Media* file );
std::shared_ptr<Folder> folder( const std::string& path );
......
......@@ -166,7 +166,7 @@ void FsDiscoverer::checkFiles( fs::IDirectory* folder, Folder* parentFolder ) co
});
if ( it == end( files ) )
{
m_ml->addFile( filePath, parentFolder );
m_ml->addFile( filePath, parentFolder, folder );
continue;
}
auto file = m_fsFactory->createFile( filePath );
......@@ -178,7 +178,7 @@ void FsDiscoverer::checkFiles( fs::IDirectory* folder, Folder* parentFolder ) co
}
LOG_INFO( "Forcing file refresh ", filePath );
m_ml->deleteFile( (*it).get() );
m_ml->addFile( filePath, parentFolder );
m_ml->addFile( filePath, parentFolder, folder );
files.erase( it );
}
for ( auto file : files )
......
......@@ -59,7 +59,7 @@ TEST_F( Albums, Fetch )
TEST_F( Albums, AddTrack )
{
auto a = ml->createAlbum( "albumtag" );
auto f = ml->addFile( "track.mp3", nullptr );
auto f = ml->addFile( "track.mp3", nullptr, nullptr );
auto track = a->addTrack( f, 10, 0 );
ASSERT_NE( track, nullptr );
......@@ -79,7 +79,7 @@ TEST_F( Albums, NbTracks )
auto a = ml->createAlbum( "albumtag" );
for ( auto i = 1u; i <= 10; ++i )
{
auto f = ml->addFile( "track" + std::to_string(i) + ".mp3", nullptr );
auto f = ml->addFile( "track" + std::to_string(i) + ".mp3", nullptr, nullptr );
auto track = a->addTrack( f, i, i );
ASSERT_NE( track, nullptr );
}
......@@ -96,7 +96,7 @@ TEST_F( Albums, NbTracks )
TEST_F( Albums, SetGenre )
{
auto a = ml->createAlbum( "album" );
auto f = ml->addFile( "track.mp3", nullptr );
auto f = ml->addFile( "track.mp3", nullptr, nullptr );
auto t = a->addTrack( f, 1, 0 );
t->setGenre( "happy underground post progressive death metal" );
......@@ -168,7 +168,7 @@ TEST_F( Albums, FetchAlbumFromTrack )
{
{
auto a = ml->createAlbum( "album" );
auto f = ml->addFile( "file.mp3", nullptr );
auto f = ml->addFile( "file.mp3", nullptr, nullptr );
auto t = a->addTrack( f, 1, 0 );
f->setAlbumTrack( t );
}
......
......@@ -34,7 +34,7 @@ class AlbumTracks : public Tests
TEST_F( AlbumTracks, Create )
{
auto album = ml->createAlbum( "album" );
auto f = ml->addFile( "track1.mp3", nullptr );
auto f = ml->addFile( "track1.mp3", nullptr, nullptr );
auto track = album->addTrack( f, 1, 10 );
ASSERT_NE( nullptr, track );
ASSERT_EQ( 10u, track->discNumber() );
......@@ -48,7 +48,7 @@ TEST_F( AlbumTracks, Create )
TEST_F( AlbumTracks, Artist )
{
auto album = ml->createAlbum( "album" );
auto f = ml->addFile( "track1.mp3", nullptr );
auto f = ml->addFile( "track1.mp3", nullptr, nullptr );
auto track = album->addTrack( f, 1, 0 );
ASSERT_EQ( track->artist(), "" );
......@@ -66,7 +66,7 @@ TEST_F( AlbumTracks, Artist )
TEST_F( AlbumTracks, SetReleaseYear )
{
auto a = ml->createAlbum( "album" );
auto m = ml->addFile( "test.mp3", nullptr );
auto m = ml->addFile( "test.mp3", nullptr, nullptr );
auto t = a->addTrack( m, 1, 0 );
ASSERT_EQ( 0u, t->releaseYear() );
......
......@@ -118,7 +118,7 @@ TEST_F( Artists, AllSongs )
for (auto i = 1; i <= 3; ++i)
{
auto f = ml->addFile( "song" + std::to_string(i) + ".mp3", nullptr );
auto f = ml->addFile( "song" + std::to_string(i) + ".mp3", nullptr, nullptr );
auto res = artist->addMedia( f.get() );
ASSERT_TRUE( res );
}
......
......@@ -31,14 +31,14 @@ class AudioTracks : public Tests
TEST_F( AudioTracks, AddTrack )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) );
bool res = f->addAudioTrack( "PCM", 128, 44100, 2, "fr", "test" );
ASSERT_TRUE( res );
}
TEST_F( AudioTracks, GetSetProperties )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) );
ASSERT_NE( f, nullptr );
f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" );
auto tracks = f->audioTracks();
......@@ -68,7 +68,7 @@ TEST_F( AudioTracks, GetSetProperties )
TEST_F( AudioTracks, FetchTracks )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) );
f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" );
f->addAudioTrack( "WMA", 128, 48000, 2, "fr", "test desc 2" );
......
......@@ -32,7 +32,7 @@ class Labels : public Tests
TEST_F( Labels, Add )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" );
......@@ -54,7 +54,7 @@ TEST_F( Labels, Add )
TEST_F( Labels, Remove )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" );
......@@ -97,9 +97,9 @@ TEST_F( Labels, Remove )
TEST_F( Labels, Files )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f2 = ml->addFile( "file.mp3", nullptr );
auto f3 = ml->addFile( "otter.mkv", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto f2 = ml->addFile( "file.mp3", nullptr, nullptr );
auto f3 = ml->addFile( "otter.mkv", nullptr, nullptr );
auto l1 = ml->createLabel( "label1" );
auto l2 = ml->createLabel( "label2" );
......@@ -124,7 +124,7 @@ TEST_F( Labels, Files )
TEST_F( Labels, Delete )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" );
......
......@@ -40,7 +40,7 @@ TEST_F( Medias, Init )
TEST_F( Medias, Create )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
ASSERT_NE( f, nullptr );
ASSERT_EQ( f->playCount(), 0 );
......@@ -58,7 +58,7 @@ TEST_F( Medias, Create )
TEST_F( Medias, Fetch )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto f2 = std::static_pointer_cast<Media>( ml->file( "media.avi" ) );
ASSERT_EQ( f->mrl(), f2->mrl() );
ASSERT_EQ( f, f2 );
......@@ -73,7 +73,7 @@ TEST_F( Medias, Fetch )
TEST_F( Medias, Delete )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
auto f2 = ml->file( "media.avi" );
ASSERT_EQ( f, f2 );
......@@ -85,7 +85,7 @@ TEST_F( Medias, Delete )
TEST_F( Medias, LastModificationDate )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
ASSERT_NE( 0u, f->lastModificationDate() );
Reload();
......@@ -95,7 +95,7 @@ TEST_F( Medias, LastModificationDate )
TEST_F( Medias, Duration )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
ASSERT_EQ( f->duration(), -1 );
// Use a value that checks we're using a 64bits value
......@@ -114,7 +114,7 @@ TEST_F( Medias, Duration )
TEST_F( Medias, Artist )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "media.avi", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "media.avi", nullptr, nullptr ) );
ASSERT_EQ( f->artist(), "" );
std::string newArtist( "Rage Against The Otters" );
......@@ -131,7 +131,7 @@ TEST_F( Medias, Artist )
TEST_F( Medias, Snapshot )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
ASSERT_EQ( f->snapshot(), "" );
std::string newSnapshot( "/path/to/snapshot" );
......@@ -148,7 +148,7 @@ TEST_F( Medias, Snapshot )
TEST_F( Medias, PlayCount )
{
auto f = ml->addFile( "media.avi", nullptr );
auto f = ml->addFile( "media.avi", nullptr, nullptr );
ASSERT_EQ( 0, f->playCount() );
f->increasePlayCount();
ASSERT_EQ( 1, f->playCount() );
......
......@@ -105,7 +105,7 @@ TEST_F( Movies, SetImdbId )
TEST_F( Movies, AssignToFile )
{
auto f = ml->addFile( "file.avi", nullptr );
auto f = ml->addFile( "file.avi", nullptr, nullptr );
auto m = ml->createMovie( "movie" );
ASSERT_EQ( f->movie(), nullptr );
......
......@@ -130,7 +130,7 @@ TEST_F( Shows, FetchShowFromEpisode )
{
auto s = ml->createShow( "show" );
auto e = s->addEpisode( "episode 1", 1 );
auto f = ml->addFile( "file.avi", nullptr );
auto f = ml->addFile( "file.avi", nullptr, nullptr );
f->setShowEpisode( e );
f->save();
......@@ -216,7 +216,7 @@ TEST_F( Shows, FileSetShowEpisode )
{
auto show = ml->createShow( "show" );
auto e = show->addEpisode( "episode 1", 1 );
auto f = ml->addFile( "file.avi", nullptr );
auto f = ml->addFile( "file.avi", nullptr, nullptr );
ASSERT_EQ( f->showEpisode(), nullptr );
f->setShowEpisode( e );
......
......@@ -31,14 +31,14 @@ class VideoTracks : public Tests
TEST_F( VideoTracks, AddTrack )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.avi", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.avi", nullptr, nullptr ) );
bool res = f->addVideoTrack( "H264", 1920, 1080, 29.97 );
ASSERT_TRUE( res );
}
TEST_F( VideoTracks, FetchTracks )
{
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.avi", nullptr ) );
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.avi", nullptr, nullptr ) );
f->addVideoTrack( "H264", 1920, 1080, 29.97 );
f->addVideoTrack( "VP80", 640, 480, 29.97 );
......
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