Skip to content

Commit

Permalink
Fix a fatal error when deleting the cache directory
Browse files Browse the repository at this point in the history
  • Loading branch information
elkuku committed Jun 19, 2016
1 parent a59c32d commit 026932f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions library/g11n/Support/ExtensionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

namespace g11n\Support;

use Joomla\Filesystem\Folder;

use g11n\g11nException;

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

/**
* Extension helper class.
*
Expand Down Expand Up @@ -92,13 +93,19 @@ public static function getCacheDir()
*/
public static function cleanCache()
{
foreach (Folder::folders(self::$cacheDir, '.', false, true) as $folder)
$filesystem = new Filesystem(new Local(self::$cacheDir));

foreach ($filesystem->listContents() as $path)
{
if (!Folder::delete($folder))
if ('dir' == $path['type'])
{
throw new \DomainException('Can not clean the cache.');
if (false == $filesystem->deleteDir($path['path']))
{
throw new \DomainException('Can not clean the cache.');
}
}
}

}

/**
Expand Down

0 comments on commit 026932f

Please sign in to comment.