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

MediaLibrary: Handle file changes

parent 94ed95e3
......@@ -340,7 +340,8 @@ void MediaLibrary::checkFiles( fs::IDirectory* folder, unsigned int parentId )
files.erase( it );
continue;
}
//FIXME: What should we do when a file is modified?! Delete & re-add?
deleteFile( filePath );
addFile( file.get(), parentId );
files.erase( it );
}
for ( auto file : files )
......
......@@ -53,6 +53,11 @@ public:
return m_lastModification;
}
void markAsModified()
{
m_lastModification++;
}
std::string m_name;
std::string m_path;
std::string m_fullPath;
......@@ -458,3 +463,22 @@ TEST_F( Folders, RemoveDirectory )
ASSERT_EQ( nullptr, f );
ASSERT_EQ( nullptr, file );
}
TEST_F( Folders, UpdateFile )
{
ml->addFolder( "." );
auto filePath = std::string{ mock::FileSystemFactory::SubFolder } + "subfile.mp4";
auto f = ml->file( filePath );
auto id = f->id();
ml.reset();
fsMock->files[filePath]->markAsModified();
fsMock->dirs[mock::FileSystemFactory::SubFolder]->markAsModified();
Reload();
f = ml->file( filePath );
ASSERT_NE( nullptr, f );
// The file is expected to be deleted and re-added since it changed, so the
// id should have changed
ASSERT_NE( id, f->id() );
}
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