Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(TB FS) path handling in copyTempfile/copyStream
Browse files Browse the repository at this point in the history
Change-Id: I325d4bfc0563389ec5d1182752a4c7446217f719
Reviewed-on: http://gerrit.tine20.com/customers/18517
Tested-by: Jenkins CI (http://ci.tine20.com/) <tine20-jenkins@metaways.de>
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
  • Loading branch information
paulmhh committed Nov 19, 2020
1 parent 95940e2 commit 042663d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tine20/Tinebase/Export/Report/Abstract.php
Expand Up @@ -120,7 +120,8 @@ protected function _saveToFilemanager($generatedExport)
$tempFile = Tinebase_TempFile::getInstance()->createTempFile($exportFilename);
$nodePath = Tinebase_Model_Tree_Node_Path::createFromRealPath($this->_fileLocation->fm_path,
Tinebase_Application::getInstance()->getApplicationByName('Filemanager'));
Tinebase_FileSystem::getInstance()->copyTempfile($tempFile, $nodePath->statpath . '/' . $index . '_' . $filename);
$targetPath = $nodePath->statpath . '/' . $index . '_' . $filename;
Tinebase_FileSystem::getInstance()->copyTempfile($tempFile, $targetPath);
}
}

Expand Down
6 changes: 4 additions & 2 deletions tine20/Tinebase/FileSystem.php
Expand Up @@ -2843,7 +2843,7 @@ public function clearDeletedFilesFromDatabase($dryRun = true)
* @return Tinebase_Model_Tree_Node
* @throws Tinebase_Exception_AccessDenied
*/
public function copyTempfile($tempFile, $path, $deleteTempFileAfterCopy = false)
public function copyTempfile($tempFile, &$path, $deleteTempFileAfterCopy = false)
{
if ($tempFile === null) {
$tempStream = fopen('php://memory', 'r');
Expand Down Expand Up @@ -2900,14 +2900,16 @@ public function setAclFromParent($path, $ifNotNull = false)
* @throws Tinebase_Exception_AccessDenied
* @throws Tinebase_Exception_UnexpectedValue
*/
public function copyStream($in, $path)
public function copyStream($in, &$path)
{
$deleteFile = !$this->fileExists($path);
try {
if (!$handle = $this->fopen($path, 'w')) {
throw new Tinebase_Exception_AccessDenied('Permission denied to create file (filename ' . $path . ')');
}

$path = stream_context_get_options($handle)['tine20']['path'];

if (!is_resource($in)) {
throw new Tinebase_Exception_UnexpectedValue('source needs to be of type stream');
}
Expand Down

0 comments on commit 042663d

Please sign in to comment.