/** * @param flavorAsset $flavor * @param StorageProfile $externalStorage */ public static function exportFlavorAsset(flavorAsset $flavor, StorageProfile $externalStorage) { if (!$externalStorage->shouldExportFlavorAsset($flavor)) { return; } $exporting = false; $keys = array($flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET), $flavor->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM), $flavor->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC)); foreach ($keys as $key) { if ($externalStorage->shoudlExportFileSync($key)) { $exporting = self::export($flavor->getentry(), $externalStorage, $key, !$flavor->getIsOriginal()); } } return $exporting; }
private function requiredToExportFlavor(StorageProfile $storage) { // check if storage profile should affect the asset ready status if ($storage->getReadyBehavior() != StorageProfileReadyBehavior::REQUIRED) { // current storage profile is not required for asset readiness - skipping return false; } // check if export should happen now or wait for another trigger if (!$storage->triggerFitsReadyAsset($this->getEntryId())) { KalturaLog::info('Asset id [' . $this->getId() . '] is not ready to export to profile [' . $storage->getId() . ']'); return false; } // check if asset needs to be exported to the remote storage if (!$storage->shouldExportFlavorAsset($this, true)) { KalturaLog::info('Should not export asset id [' . $this->getId() . '] to profile [' . $storage->getId() . ']'); return false; } $keys = array($this->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET), $this->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM), $this->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISMC)); foreach ($keys as $key) { if ($storage->shoudlExportFileSync($key)) { return true; } } foreach ($keys as $key) { // check if asset is currently being exported to the remote storage if ($storage->isPendingExport($key)) { KalturaLog::info('Asset id [' . $this->getId() . '] is currently being exported to profile [' . $storage->getId() . ']'); return true; } } return false; }