From: Michael J. Rubinsky Date: Fri, 12 Mar 2010 15:11:25 +0000 (-0500) Subject: Catch (and ignore) exceptinos from VFS when deleting ansel's image cache. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=19f2ac94b2fb2c2239cda653dff02c1fd1f35262;p=horde.git Catch (and ignore) exceptinos from VFS when deleting ansel's image cache. We don't care if the file doesn't exist when deleting it...and it saves having to stat the file before deleting it. --- diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index 0775350a4..2e57a7d19 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -753,40 +753,43 @@ class Ansel_Image Implements Iterator */ public function deleteCache($view = 'all') { - /* Delete cached screen image. */ - if ($view == 'all' || $view == 'screen') { - $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('screen'), - $this->getVFSName('screen')); - } + /* Catch exceptions from VFS */ + try { + /* Delete cached screen image. (We don't care if the file is not found) */ + if ($view == 'all' || $view == 'screen') { + $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('screen'), + $this->getVFSName('screen')); + } - /* Delete cached thumbnail. */ - if ($view == 'all' || $view == 'thumb') { - $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('thumb'), - $this->getVFSName('thumb')); - } + /* Delete cached thumbnail. */ + if ($view == 'all' || $view == 'thumb') { + $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('thumb'), + $this->getVFSName('thumb')); + } - /* Delete cached mini image. */ - if ($view == 'all' || $view == 'mini') { - $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('mini'), - $this->getVFSName('mini')); - } + /* Delete cached mini image. */ + if ($view == 'all' || $view == 'mini') { + $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath('mini'), + $this->getVFSName('mini')); + } - if ($view == 'all' || $view == 'prettythumb') { + if ($view == 'all' || $view == 'prettythumb') { - /* No need to try to delete a hash we already removed */ - $deleted = array(); + /* No need to try to delete a hash we already removed */ + $deleted = array(); - /* Need to generate hashes for each possible style */ - $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel'); - foreach ($styles as $style) { - $hash = md5($style['thumbstyle'] . '.' . $style['background']); - if (empty($deleted[$hash])) { - $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath($hash), - $this->getVFSName($hash)); - $deleted[$hash] = true; + /* Need to generate hashes for each possible style */ + $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel'); + foreach ($styles as $style) { + $hash = md5($style['thumbstyle'] . '.' . $style['background']); + if (empty($deleted[$hash])) { + $GLOBALS['ansel_vfs']->deleteFile($this->getVFSPath($hash), + $this->getVFSName($hash)); + $deleted[$hash] = true; + } } } - } + } catch (VFS_Exception $e) {} } /**