From 771599bcb69ebf0fbffd42c1aa9fa09ee4f85ea5 Mon Sep 17 00:00:00 2001 From: Brad Shuttleworth Date: Thu, 17 Aug 2006 15:52:54 +0000 Subject: [PATCH] (NBM: Please review - are there issues with unlink on windows?) - actually use the error return if we get one from FSFileLike - allow cleanup of the file we uploaded (needed with new add code). --- lib/documentmanagement/documentutil.inc.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index e115bb0..d8a4049 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -556,14 +556,24 @@ class KTDocumentUtil { $sFilename = tempnam($sBasedir, 'kt_storecontents'); $oOutputFile = new KTFSFileLike($sFilename); $res = KTFileLikeUtil::copy_contents($oContents, $oOutputFile); + if (($res === false)) { + return PEAR::raiseError(_kt("Couldn't store contents, and no reason given.")); + } else if (PEAR::isError($res)) { + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); + } $sType = KTMime::getMimeTypeFromFile($sFilename); $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName()); $oDocument->setMimeTypeId($iMimeTypeId); $res = $oStorage->upload($oDocument, $sFilename); - if (($res == false) || PEAR::isError($res)) { - return PEAR::raiseError("Couldn't store contents"); + if (($res === false) || PEAR::isError($res)) { + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); } KTDocumentUtil::setComplete($oDocument, "contents"); + + if ($aOptions['cleanup_initial_file']) { + unlink($oContents->sFilename); + } + return true; } // }}} -- libgit2 0.21.4