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

Thumbnail: Simplify previous thumbnail files removal

parent faa80596
......@@ -351,13 +351,22 @@ Thumbnail::updateOrReplace( MediaLibraryPtr ml,
* the new one
*/
assert( newThumbnail->isOwned() == false );
if ( oldThumbnail->isOwned() )
{
auto path = Thumbnail::path( ml, oldThumbnail->id() );
utils::fs::remove( path );
}
if ( newThumbnail->id() == 0 )
{
/*
* We are about to use a non-owned thumbnail. Since we are
* keeping the same thumbnail entity, we need to cleanup the
* previously generated thumbnail before updating the MRL
* If we were switching to another thumbnail, this wouldn't be
* required since owned thumbnail are cleaned up after they are
* removed from DB
*/
if ( oldThumbnail->isOwned() )
{
auto path = Thumbnail::path( ml, oldThumbnail->id() );
utils::fs::remove( path );
}
/*
* If the thumbnail was not inserted, we just have to update the
* mrl in database
......
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