-
Notifications
You must be signed in to change notification settings - Fork 183
fix(SUP-51410): Add fileProcessingGracePeriod to a per-drop-folder setting #13831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Venus-22.15.0
Are you sure you want to change the base?
Changes from 10 commits
70d52ad
d5eaf3b
143ef6c
61ba3d3
dd988ef
79eddac
96f01b6
e58c923
9fce4e9
21f7fef
19d2d68
9ca208e
289c0a8
75eda26
c9dca1b
b4eae25
43adf5c
fe38809
4954ed7
987c280
4b933eb
6f23e4a
db0e47b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,13 @@ class KalturaDropFolder extends KalturaObject implements IFilterable | |
| * @var int | ||
| */ | ||
| public $fileSizeCheckInterval; | ||
|
|
||
|
|
||
| /** | ||
| * The amount of time, in seconds, to wait before processing a drop folder file | ||
| * @var int | ||
| */ | ||
| public $fileProcessingGracePeriod; | ||
|
||
|
|
||
| /** | ||
| * @var KalturaDropFolderFileDeletePolicy | ||
| */ | ||
|
|
@@ -184,6 +190,7 @@ class KalturaDropFolder extends KalturaObject implements IFilterable | |
| 'dc', | ||
| 'path', | ||
| 'fileSizeCheckInterval', | ||
| 'fileProcessingGracePeriod', | ||
| 'fileDeletePolicy', | ||
| 'fileDeleteRegex', | ||
| 'autoFileDeleteDays', | ||
|
|
@@ -213,21 +220,55 @@ public function toObject($dbObject = null, $skip = array()) | |
| { | ||
| if (is_null($dbObject)) | ||
| $dbObject = new DropFolder(); | ||
| $this->trimStringProperties(array ('path')); | ||
| $this->trimStringProperties(array ('path')); | ||
|
|
||
| // Set fileProcessingGracePeriod BEFORE calling parent to preserve user value | ||
| // (parent may not recognize this property due to reflection cache) | ||
| $fileProcessingGracePeriodValue = $this->fileProcessingGracePeriod; | ||
|
|
||
| // Convert to integer if it's a numeric string | ||
| if (is_string($fileProcessingGracePeriodValue) && is_numeric($fileProcessingGracePeriodValue)) { | ||
|
||
| $fileProcessingGracePeriodValue = (int)$fileProcessingGracePeriodValue; | ||
| } | ||
|
|
||
| // Set default if empty | ||
| if (is_null($fileProcessingGracePeriodValue) || $fileProcessingGracePeriodValue === '' || $fileProcessingGracePeriodValue === 0) { | ||
|
||
| $fileProcessingGracePeriodValue = DropFolder::FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE; | ||
| } | ||
|
|
||
| // Validate maximum value | ||
| if ($fileProcessingGracePeriodValue > DropFolder::FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE) { | ||
| throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'fileProcessingGracePeriod'); | ||
| } | ||
|
|
||
| parent::toObject($dbObject, $skip); | ||
|
|
||
| // Explicitly set fileProcessingGracePeriod to ensure it's saved | ||
| if (!is_null($fileProcessingGracePeriodValue) && !in_array('fileProcessingGracePeriod', $skip)) | ||
| { | ||
| $dbObject->setFileProcessingGracePeriod($fileProcessingGracePeriodValue); | ||
| } | ||
|
|
||
| if ($this->fileHandlerConfig) | ||
| { | ||
| $dbFileHandlerConfig = $this->fileHandlerConfig->toObject(); | ||
| $dbObject->setFileHandlerConfig($dbFileHandlerConfig); | ||
| } | ||
|
|
||
| return $dbObject; | ||
| } | ||
|
|
||
| public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null) | ||
| { | ||
| parent::doFromObject($source_object, $responseProfile); | ||
|
|
||
|
|
||
| // Explicitly load fileProcessingGracePeriod from database object | ||
| // (parent may not recognize this property due to reflection cache) | ||
| if ($this->shouldGet('fileProcessingGracePeriod', $responseProfile)) | ||
| { | ||
| $this->fileProcessingGracePeriod = $source_object->getFileProcessingGracePeriod(); | ||
|
||
| } | ||
|
|
||
| if($this->shouldGet('fileHandlerConfig', $responseProfile)) | ||
| { | ||
| $dbFileHandlerConfig = $source_object->getFileHandlerConfig(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ class DropFolder extends BaseDropFolder implements IBaseObject | |
| const AUTO_FILE_DELETE_DAYS_DEFAULT_VALUE = 0; | ||
| const FILE_SIZE_CHECK_INTERVAL_DEFAULT_VALUE = '600'; // 600 seconds = 10 minutes | ||
| const FILE_NAME_PATTERNS_DEFAULT_VALUE = '*'; | ||
| const FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE = 10800; // 10800 seconds = 3 hours | ||
| const FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE = 21600; // 21600 seconds = 6 hours | ||
| const INCREMENTAL = 'incremental'; | ||
| const LAST_FILE_TIMESTAMP = 'last_file_timestamp'; | ||
| const METADATA_PROFILE_ID = 'metadata_profile_id'; | ||
|
|
@@ -52,8 +54,13 @@ public function preInsert(PropelPDO $con = null) | |
|
|
||
| if (is_null($this->getAutoFileDeleteDays())) { | ||
| $this->setAutoFileDeleteDays(DropFolder::AUTO_FILE_DELETE_DAYS_DEFAULT_VALUE); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| $currentValue = $this->getFileProcessingGracePeriod(); | ||
| if (is_null($currentValue)) { | ||
| $this->setFileProcessingGracePeriod(DropFolder::FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE); | ||
| } | ||
|
|
||
| return $ret; | ||
| } | ||
|
|
||
|
|
@@ -135,6 +142,7 @@ public function setFileHandlerConfig($fileHandlerConfig) | |
| const CUSTOM_DATA_IGNORE_FILE_NAME_PATTERNS = 'ignore_file_name_patterns'; | ||
| const CUSTOM_DATA_LAST_ACCESSED_AT = 'last_accessed_at'; | ||
| const CUSTOM_DATA_FILE_DELETE_REGEX = 'file_delete_regex'; | ||
| const CUSTOM_DATA_FILE_PROCESSING_GRACE_PERIOD = 'file_processing_grace_period'; | ||
|
|
||
|
|
||
| // File size check interval - value in seconds | ||
|
|
@@ -169,6 +177,21 @@ public function setFileDeleteRegex($fileDeleteRegex) | |
| $this->putInCustomData(self::CUSTOM_DATA_FILE_DELETE_REGEX, $fileDeleteRegex); | ||
| } | ||
|
|
||
| // File processing grace period | ||
|
|
||
| /** | ||
| * @return int | ||
| */ | ||
| public function getFileProcessingGracePeriod() | ||
| { | ||
| return $this->getFromCustomData(self::CUSTOM_DATA_FILE_PROCESSING_GRACE_PERIOD); | ||
|
||
| } | ||
|
|
||
| public function setFileProcessingGracePeriod($seconds) | ||
| { | ||
| $this->putInCustomData(self::CUSTOM_DATA_FILE_PROCESSING_GRACE_PERIOD, $seconds); | ||
| } | ||
|
|
||
| // Automatic file delete days | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,11 +23,11 @@ public function initService($serviceId, $serviceName, $actionName) | |
|
|
||
| /** | ||
| * Allows you to add a new KalturaDropFolder object | ||
| * | ||
| * | ||
| * @action add | ||
| * @param KalturaDropFolder $dropFolder | ||
| * @return KalturaDropFolder | ||
| * | ||
| * | ||
| * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL | ||
| * @throws KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND | ||
| * @throws KalturaDropFolderErrors::DROP_FOLDER_ALREADY_EXISTS | ||
|
|
@@ -43,28 +43,43 @@ public function addAction(KalturaDropFolder $dropFolder) | |
| $dropFolder->validatePropertyNotNull('path'); | ||
| $dropFolder->validatePropertyNotNull('partnerId'); | ||
| $dropFolder->validatePropertyMinValue('fileSizeCheckInterval', 0, true); | ||
| $dropFolder->validatePropertyMinValue('fileProcessingGracePeriod', 0, true); | ||
|
||
| $dropFolder->validatePropertyMinValue('autoFileDeleteDays', 0, true); | ||
| $dropFolder->validatePropertyNotNull('fileHandlerType'); | ||
| $dropFolder->validatePropertyNotNull('fileHandlerConfig'); | ||
|
|
||
| // validate values | ||
|
|
||
| if (is_null($dropFolder->fileSizeCheckInterval)) { | ||
| $dropFolder->fileSizeCheckInterval = DropFolder::FILE_SIZE_CHECK_INTERVAL_DEFAULT_VALUE; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| // Convert to integer if it's a numeric string | ||
|
||
| if (is_string($dropFolder->fileProcessingGracePeriod) && is_numeric($dropFolder->fileProcessingGracePeriod)) { | ||
| $dropFolder->fileProcessingGracePeriod = (int)$dropFolder->fileProcessingGracePeriod; | ||
| } | ||
|
|
||
| if (is_null($dropFolder->fileProcessingGracePeriod) || $dropFolder->fileProcessingGracePeriod === '' || $dropFolder->fileProcessingGracePeriod === 0) { | ||
| $dropFolder->fileProcessingGracePeriod = DropFolder::FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE; | ||
| } | ||
|
|
||
| if ($dropFolder->fileProcessingGracePeriod > DropFolder::FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE) { | ||
| throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'fileProcessingGracePeriod'); | ||
| } | ||
|
|
||
| if (is_null($dropFolder->fileNamePatterns)) { | ||
| $dropFolder->fileNamePatterns = DropFolder::FILE_NAME_PATTERNS_DEFAULT_VALUE; | ||
| } | ||
|
|
||
| if (!kDataCenterMgr::dcExists($dropFolder->dc)) { | ||
| throw new KalturaAPIException(KalturaErrors::DATA_CENTER_ID_NOT_FOUND, $dropFolder->dc); | ||
| } | ||
|
|
||
| if (!PartnerPeer::retrieveByPK($dropFolder->partnerId)) { | ||
| throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $dropFolder->partnerId); | ||
| } | ||
|
|
||
| if (!DropFolderPlugin::isAllowedPartner($dropFolder->partnerId)) | ||
| { | ||
| throw new KalturaAPIException(KalturaErrors::PLUGIN_NOT_AVAILABLE_FOR_PARTNER, DropFolderPlugin::getPluginName(), $dropFolder->partnerId); | ||
|
|
@@ -77,34 +92,34 @@ public function addAction(KalturaDropFolder $dropFolder) | |
| throw new KalturaAPIException(KalturaDropFolderErrors::DROP_FOLDER_ALREADY_EXISTS, $dropFolder->path); | ||
| } | ||
| } | ||
|
|
||
| if (!is_null($dropFolder->conversionProfileId)) { | ||
| $conversionProfileDb = conversionProfile2Peer::retrieveByPK($dropFolder->conversionProfileId); | ||
| if (!$conversionProfileDb) { | ||
| throw new KalturaAPIException(KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND, $dropFolder->conversionProfileId); | ||
| } | ||
| } | ||
|
|
||
| // save in database | ||
| $dbDropFolder = $dropFolder->toInsertableObject(); | ||
| $dbDropFolder->save(); | ||
|
|
||
| // return the saved object | ||
| $dropFolder = KalturaDropFolder::getInstanceByType($dbDropFolder->getType()); | ||
| $dropFolder->fromObject($dbDropFolder, $this->getResponseProfile()); | ||
| return $dropFolder; | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Retrieve a KalturaDropFolder object by ID | ||
| * | ||
| * | ||
| * @action get | ||
| * @param int $dropFolderId | ||
| * @param int $dropFolderId | ||
| * @return KalturaDropFolder | ||
| * | ||
| * | ||
| * @throws KalturaErrors::INVALID_OBJECT_ID | ||
| */ | ||
| */ | ||
| public function getAction($dropFolderId) | ||
| { | ||
| $dbDropFolder = DropFolderPeer::retrieveByPK($dropFolderId); | ||
|
|
@@ -141,8 +156,14 @@ public function updateAction($dropFolderId, KalturaDropFolder $dropFolder) | |
| } | ||
|
|
||
| $dropFolder->validatePropertyMinValue('fileSizeCheckInterval', 0, true); | ||
| $dropFolder->validatePropertyMinValue('fileProcessingGracePeriod', 0, true); | ||
| $dropFolder->validatePropertyMinValue('autoFileDeleteDays', 0, true); | ||
|
|
||
|
|
||
| // Validate fileProcessingGracePeriod does not exceed maximum value | ||
| if (!is_null($dropFolder->fileProcessingGracePeriod) && $dropFolder->fileProcessingGracePeriod > DropFolder::FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE) { | ||
| throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'fileProcessingGracePeriod'); | ||
| } | ||
|
|
||
| if (!is_null($dropFolder->path) && $dropFolder->path != $dbDropFolder->getPath() && $dropFolder->type == KalturaDropFolderType::LOCAL) | ||
| { | ||
| $existingDropFolder = DropFolderPeer::retrieveByPathDefaultFilter($dropFolder->path); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is only relevant for Zoom, lets keep it only there