Skip to content

Commit

Permalink
Merge branch 'pu/ccheng/rt_244385' into '2024.11'
Browse files Browse the repository at this point in the history
fix(Tinebase/WebDav): skip avscan for new webdav uploaded file

See merge request tine20/tine20!6588
  • Loading branch information
pschuele committed Feb 17, 2025
2 parents 5796831 + 3fd1cb5 commit c1d43fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 9 additions & 5 deletions tine20/Tinebase/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public function fileExists($path, $revision = null)
* @param resource $handle
* @return boolean
*/
public function fclose($handle)
public function fclose($handle, $avscan = true)
{
if (!is_resource($handle)) {
return false;
Expand All @@ -724,7 +724,7 @@ public function fclose($handle)
$hashFile = 'flySystem'; // we need to set a true-ish string value here
$avResult = null; // FIXME todo add avScanning for FlySystem
} else {
list ($hash, $hashFile, $avResult) = $this->createFileBlob($handle);
list ($hash, $hashFile, $avResult) = $this->createFileBlob($handle, $avscan);
}

try {
Expand Down Expand Up @@ -2487,7 +2487,7 @@ public function checkHashFile(string $hash)
* @throws Tinebase_Exception_NotImplemented
* @throws Tinebase_Exception_UnexpectedValue
*/
public function createFileBlob($contents)
public function createFileBlob($contents, $avscan = true)
{
if (! is_resource($contents)) {
throw new Tinebase_Exception_NotImplemented('please implement me!');
Expand Down Expand Up @@ -2532,8 +2532,12 @@ public function createFileBlob($contents)
}

// AV scan
$avResult = $this->avScanHashFile($hashFile);

if ($avscan) {
$avResult = $this->avScanHashFile($hashFile);
} else {
$avResult = null;
}

$tries = 0;
$currentFilesHash = null;
$previousCurrentFilesHash = null;
Expand Down
4 changes: 2 additions & 2 deletions tine20/Tinebase/Frontend/WebDAV/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function createFile($name, $data = null)
throw new Sabre\DAV\Exception('data should be a resource');
}

if (true !== Tinebase_FileSystem::getInstance()->fclose($handle)) {
if (true !== Tinebase_FileSystem::getInstance()->fclose($handle, false)) {
throw new Sabre\DAV\Exception('Tinebase_FileSystem::fclose failed for path ' . $path);
}

Expand Down Expand Up @@ -379,7 +379,7 @@ public static function handleOwnCloudChunkedFileUpload($name, $data)
}

// combine all chunks to one file
$joinedFile = Tinebase_TempFile::getInstance()->joinTempFiles($uploadedChunks);
$joinedFile = Tinebase_TempFile::getInstance()->joinTempFiles($uploadedChunks, false);
$joinedFile->name = $chunkInfo['name'];

return $joinedFile;
Expand Down
5 changes: 3 additions & 2 deletions tine20/Tinebase/TempFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function createTempFile($_path, $_name = 'tempfile.tmp', $_type = 'unknow
* @return Tinebase_Model_TempFile
* @throws Tinebase_Exception_Backend
*/
public function joinTempFiles($_tempFiles)
public function joinTempFiles($_tempFiles, $avscan = true)
{
$path = self::getTempPath();
$name = preg_replace('/\.\d+\.chunk$/', '', $_tempFiles->getFirstRecord()->name);
Expand All @@ -262,8 +262,9 @@ public function joinTempFiles($_tempFiles)
fclose($fChunk);
}

if (Tinebase_FileSystem_AVScan_Factory::MODE_OFF !== Tinebase_Config::getInstance()
if ($avscan && Tinebase_FileSystem_AVScan_Factory::MODE_OFF !== Tinebase_Config::getInstance()
->{Tinebase_Config::FILESYSTEM}->{Tinebase_Config::FILESYSTEM_AVSCAN_MODE}) {
// fixme: large file might lead to gateway timeout, we wait for the schedular task to scan the large files for now
$this->_avScan($fJoin, $path);
}

Expand Down

0 comments on commit c1d43fd

Please sign in to comment.