From eee5dec0005bd3cf07a342eac79ab7c3eac5c40b Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 30 Mar 2010 12:55:36 -0400 Subject: [PATCH] Ignore exceptions from VFS when deleting the image cache --- ansel/lib/Faces.php | 14 ++++++++------ ansel/lib/GalleryMode/Date.php | 6 ++++-- ansel/lib/GalleryMode/Normal.php | 6 ++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ansel/lib/Faces.php b/ansel/lib/Faces.php index 0ddec859d..786805e7e 100644 --- a/ansel/lib/Faces.php +++ b/ansel/lib/Faces.php @@ -52,16 +52,18 @@ class Ansel_Faces if ($face instanceof PEAR_Error) { throw new Horde_Exception_Prior($face); } - - foreach ($face as $id) { - $GLOBALS['ansel_vfs']->deleteFile($path, $id . $ext); - } - + try { + foreach ($face as $id) { + $GLOBALS['ansel_vfs']->deleteFile($path, $id . $ext); + } + } catch (VFS_Exception $e) {} $GLOBALS['ansel_db']->exec('DELETE FROM ansel_faces WHERE image_id = ' . $image->id); $GLOBALS['ansel_db']->exec('UPDATE ansel_images SET image_faces = 0 WHERE image_id = ' . $image->id . ' AND image_faces > 0 '); $GLOBALS['ansel_db']->exec('UPDATE ansel_shares SET attribute_faces = attribute_faces - ' . count($face) . ' WHERE gallery_id = ' . $image->gallery . ' AND attribute_faces > 0 '); } else { - $GLOBALS['ansel_vfs']->deleteFile($path, (int)$face . $ext); + try { + $GLOBALS['ansel_vfs']->deleteFile($path, (int)$face . $ext); + } catch (VFS_Exception $e) {} $GLOBALS['ansel_db']->exec('DELETE FROM ansel_faces WHERE face_id = ' . (int)$face); $GLOBALS['ansel_db']->exec('UPDATE ansel_images SET image_faces = image_faces - 1 WHERE image_id = ' . $image->id . ' AND image_faces > 0 '); $GLOBALS['ansel_db']->exec('UPDATE ansel_shares SET attribute_faces = attribute_faces - 1 WHERE gallery_id = ' . $image->gallery . ' AND attribute_faces > 0 '); diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 2ec55ab6c..ac868005b 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -520,8 +520,10 @@ class Ansel_GalleryMode_Date { $image->deleteCache(); /* Delete original image from VFS. */ - $GLOBALS['ansel_vfs']->deleteFile($image->getVFSPath('full'), - $image->getVFSName('full')); + try { + $GLOBALS['ansel_vfs']->deleteFile($image->getVFSPath('full'), + $image->getVFSName('full')); + } catch (VFS_Exception $e) {} /* Delete from SQL. */ $this->_gallery->_shareOb->_write_db->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); diff --git a/ansel/lib/GalleryMode/Normal.php b/ansel/lib/GalleryMode/Normal.php index 4fb9cf0f7..0915dd673 100644 --- a/ansel/lib/GalleryMode/Normal.php +++ b/ansel/lib/GalleryMode/Normal.php @@ -226,8 +226,10 @@ class Ansel_GalleryMode_Normal { $image->deleteCache(); /* Delete original image from VFS. */ - $GLOBALS['ansel_vfs']->deleteFile($image->getVFSPath('full'), - $image->getVFSName('full')); + try { + $GLOBALS['ansel_vfs']->deleteFile($image->getVFSPath('full'), + $image->getVFSName('full')); + } catch (VFS_Exception $e) {} /* Delete from SQL. */ $this->_gallery->_shareOb->_write_db->exec('DELETE FROM ansel_images WHERE image_id = ' . (int)$image->id); -- 2.11.0