Commit a10931e79e53ef006662742df2357b2594c50d66
1 parent
7c40350a
(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). git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5862 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
12 additions
and
2 deletions
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -556,14 +556,24 @@ class KTDocumentUtil { |
| 556 | 556 | $sFilename = tempnam($sBasedir, 'kt_storecontents'); |
| 557 | 557 | $oOutputFile = new KTFSFileLike($sFilename); |
| 558 | 558 | $res = KTFileLikeUtil::copy_contents($oContents, $oOutputFile); |
| 559 | + if (($res === false)) { | |
| 560 | + return PEAR::raiseError(_kt("Couldn't store contents, and no reason given.")); | |
| 561 | + } else if (PEAR::isError($res)) { | |
| 562 | + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); | |
| 563 | + } | |
| 559 | 564 | $sType = KTMime::getMimeTypeFromFile($sFilename); |
| 560 | 565 | $iMimeTypeId = KTMime::getMimeTypeID($sType, $oDocument->getFileName()); |
| 561 | 566 | $oDocument->setMimeTypeId($iMimeTypeId); |
| 562 | 567 | $res = $oStorage->upload($oDocument, $sFilename); |
| 563 | - if (($res == false) || PEAR::isError($res)) { | |
| 564 | - return PEAR::raiseError("Couldn't store contents"); | |
| 568 | + if (($res === false) || PEAR::isError($res)) { | |
| 569 | + return PEAR::raiseError(sprintf(_kt("Couldn't store contents: %s"), $res->getMessage())); | |
| 565 | 570 | } |
| 566 | 571 | KTDocumentUtil::setComplete($oDocument, "contents"); |
| 572 | + | |
| 573 | + if ($aOptions['cleanup_initial_file']) { | |
| 574 | + unlink($oContents->sFilename); | |
| 575 | + } | |
| 576 | + | |
| 567 | 577 | return true; |
| 568 | 578 | } |
| 569 | 579 | // }}} | ... | ... |