Skip to content

Commit

Permalink
Don't delete mime icons if they are part of the same fs base directory
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Oct 17, 2019
1 parent 36e21e7 commit fcc8567
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions controller/common/src/Controller/Common/Media/Standard.php
Expand Up @@ -132,6 +132,7 @@ public function delete( \Aimeos\MShop\Media\Item\Iface $item, $fsname = 'fs-medi
return $item->setUrl( '' )->setPreview( '' );
}

$mimedir = (string) $this->context->getConfig()->get( 'controller/common/media/standard/mimeicon/directory' );
$fs = $this->context->getFilesystemManager()->get( $fsname );
$path = $item->getUrl();

Expand All @@ -143,11 +144,11 @@ public function delete( \Aimeos\MShop\Media\Item\Iface $item, $fsname = 'fs-medi
{
try
{
if( $preview !== '' && $fs->has( $preview ) ) {
if( $preview !== '' && !strcmp( $preview, $mimedir ) && $fs->has( $preview ) ) {
$fs->rm( $preview );
}
}
catch( \Exception $e ) { ; } // Can be a mime icon with relative path
catch( \Exception $e ) { ; } // continue if removing file fails
}

return $item->setUrl( '' )->setPreviews( [] )->deletePropertyItems( $item->getPropertyItems() );
Expand Down

0 comments on commit fcc8567

Please sign in to comment.