mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
better error handling in addDocumentFile()
This commit is contained in:
parent
71a24bb826
commit
4021d62cb3
|
@ -2214,14 +2214,21 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
$dir = $this->getDir();
|
||||
|
||||
$db->startTransaction();
|
||||
$queryStr = "INSERT INTO `tblDocumentFiles` (`comment`, `date`, `dir`, `document`, `fileType`, `mimeType`, `orgFileName`, `userID`, `name`, `version`, `public`) VALUES ".
|
||||
"(".$db->qstr($comment).", ".$db->getCurrentTimestamp().", ".$db->qstr($dir).", ".$this->_id.", ".$db->qstr($fileType).", ".$db->qstr($mimeType).", ".$db->qstr($orgFileName).",".$user->getID().",".$db->qstr($name).", ".((int) $version).", ".($public ? 1 : 0).")";
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$id = $db->getInsertID('tblDocumentFiles');
|
||||
|
||||
$file = $this->getDocumentFile($id);
|
||||
if (is_bool($file) && !$file) return false;
|
||||
if (is_bool($file) && !$file) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy file
|
||||
if (!SeedDMS_Core_File::makeDir($this->_dms->contentDir . $dir)) return false;
|
||||
|
@ -2229,8 +2236,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
$err = SeedDMS_Core_File::renameFile($tmpFile, $this->_dms->contentDir . $file->getPath());
|
||||
else
|
||||
$err = SeedDMS_Core_File::copyFile($tmpFile, $this->_dms->contentDir . $file->getPath());
|
||||
if (!$err) return false;
|
||||
if (!$err) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return $file;
|
||||
} /* }}} */
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user