From ea2de6fe3c848644d8c55d022193894736f459a0 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sat, 9 Jun 2007 22:17:32 +0000 Subject: [PATCH] Screenshot::delete() and Image::delete() should check if the file exists before attempting to call unlink() on it. Fixes three php errors that occur during the unit tests. --- include/image.php | 4 +++- include/screenshot.php | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/image.php b/include/image.php index 3ca29fb..16e45dc 100644 --- a/include/image.php +++ b/include/image.php @@ -391,7 +391,9 @@ class Image { */ function delete() { - unlink($this->sFile); + // if the file exists, delete it + if(is_file($this->sFile)) + unlink($this->sFile); } diff --git a/include/screenshot.php b/include/screenshot.php index dbe3657..9a33433 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -139,7 +139,12 @@ class Screenshot { $this->oScreenshotImage->delete(); $this->oThumbnailImage->delete(); - unlink(appdb_fullpath("/data/screenshots/originals/".$this->iScreenshotId)); + + // if the original file exists, delete it + $sOriginalFilename = appdb_fullpath("/data/screenshots/originals/".$this->iScreenshotId); + if(is_file($sOriginalFilename)) + unlink($sOriginalFilename); + if(!$bSilent) $this->mailMaintainers(true); }