Skip to content

Commit

Permalink
Modify the content attribute synchronous to avoid publishing with emp…
Browse files Browse the repository at this point in the history
…ty attribute
  • Loading branch information
dennisxrow committed Mar 13, 2018
1 parent 592053a commit 33631a5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions modules/xrowvideo/upload.php
Expand Up @@ -54,6 +54,7 @@
$async = true;
}


if($fileHandler == "eZDFSFileHandler")
{
$nfs = true;
Expand Down Expand Up @@ -205,23 +206,14 @@
* The directories will get deleted by xrowMedia->updateMediaInfo()
* \_ eZDFSFileHandler->deleteLocal()
* \_ eZClusterFileHandler::cleanupEmptyDirectories()
* if the local file was the only file inside that directory tree.
* if local file was the only file inside that directory tree.
*/
if (!file_exists(dirname($storeName))) {
mkdir(dirname($storeName), 0777, true);
}

rename($storeNameNFS, $storeName);

$contentObjectAttributeID = $attribute->attribute( 'id' );
$version = $attribute->attribute( 'version' );

$binary = eZBinaryFile::create( $contentObjectAttributeID, $version );
$binary->setAttribute( 'filename', basename( $storeName ) );
$binary->setAttribute( 'original_filename', $fileName );
$binary->setAttribute( 'mime_type', $mime['name'] );
$binary->store();

$fileHandler = eZClusterFileHandler::instance();
// fileStore() is slow with large files
$fileHandler->fileStore( $storeName, 'binaryfile', false, $mime['name'] );
Expand All @@ -240,6 +232,18 @@

// Store the received file if its the last chunk or if the data was send via streaming
if( (isset( $_REQUEST['chunk'] ) && $chunk == $targetchunk) || !isset( $_REQUEST['chunk'])) {
$db = eZDB::instance();
$db->begin();
$contentObjectAttributeID = $attribute->attribute( 'id' );
$version = $attribute->attribute( 'version' );

$binary = eZBinaryFile::create( $contentObjectAttributeID, $version );
$binary->setAttribute( 'filename', basename( $storeName ) );
$binary->setAttribute( 'original_filename', $fileName );
$binary->setAttribute( 'mime_type', $mime['name'] );
$binary->store();
$db->commit();

// If AsyncFileTransfer is enabled perform the file processing asynchronous to prevent timeouts, otherwise just execute it
if ($async) {
// AsyncFileTransfer requires xrow mq-bundle installed and at least eZ 5.4
Expand All @@ -249,6 +253,7 @@
} else {
$closure();
}

eZLog::write( gmdate( 'D, d M Y H:i:s', time() ) . " ObjectID #" . $obj->ID . " completed", "xrowvideo.log");
}

Expand Down

0 comments on commit 33631a5

Please sign in to comment.