コード例 #1
0
 private function moveExtraFiles(KalturaConvertJobData &$data, $sharedFile)
 {
     $i = 0;
     foreach ($data->extraDestFileSyncs as $destFileSync) {
         $i++;
         clearstatcache();
         $directorySync = is_dir($destFileSync->fileSyncLocalPath);
         if ($directorySync) {
             $fileSize = KBatchBase::foldersize($destFileSync->fileSyncLocalPath);
         } else {
             $fileSize = kFile::fileSize($destFileSync->fileSyncLocalPath);
         }
         $ext = pathinfo($destFileSync->fileSyncLocalPath, PATHINFO_EXTENSION);
         if ($ext) {
             $newName = $sharedFile . '.' . $ext;
         } else {
             $newName = $sharedFile . '.' . $i;
         }
         kFile::moveFile($destFileSync->fileSyncLocalPath, $newName);
         // directory sizes may differ on different devices
         if (!file_exists($newName) || is_file($newName) && kFile::fileSize($newName) != $fileSize) {
             KalturaLog::err("Error: moving file failed");
             die;
         }
         $destFileSync->fileSyncLocalPath = $this->translateLocalPath2Shared($newName);
         if (self::$taskConfig->params->isRemoteOutput) {
             $destFileSync->fileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($destFileSync->fileSyncLocalPath);
         }
     }
 }
コード例 #2
0
 private function moveFile(KalturaBatchJob $job, KalturaConvertJobData $data)
 {
     KalturaLog::debug("moveFile({$job->id}, {$data->destFileSyncLocalPath})");
     $uniqid = uniqid("convert_{$job->entryId}_");
     $sharedFile = "{$this->sharedTempPath}/{$uniqid}";
     clearstatcache();
     $fileSize = filesize($data->destFileSyncLocalPath);
     @rename($data->destFileSyncLocalPath . '.log', "{$sharedFile}.log");
     kFile::moveFile($data->destFileSyncLocalPath, $sharedFile);
     if (!file_exists($sharedFile) || filesize($sharedFile) != $fileSize) {
         KalturaLog::err("Error: moving file failed");
         die;
     }
     @chmod($sharedFile, 0777);
     $data->destFileSyncLocalPath = $this->translateLocalPath2Shared($sharedFile);
     if ($this->taskConfig->params->isRemote) {
         $data->destFileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($data->destFileSyncLocalPath);
         $job->status = KalturaBatchJobStatus::ALMOST_DONE;
         $job->message = "File ready for download";
     } elseif ($this->checkFileExists($data->destFileSyncLocalPath, $fileSize)) {
         $job->status = KalturaBatchJobStatus::FINISHED;
         $job->message = "File moved to shared";
     } else {
         $job->status = KalturaBatchJobStatus::RETRY;
         $job->message = "File not moved correctly";
     }
     return $this->closeJob($job, null, null, $job->message, $job->status, $data);
 }
 private function moveFile(KalturaBatchJob $job, KalturaConvertJobData $data)
 {
     KalturaLog::debug("moveFile({$job->id}, {$data->destFileSyncLocalPath})");
     $uniqid = uniqid("convert_{$job->entryId}_");
     $sharedFile = "{$this->sharedTempPath}/{$uniqid}";
     if (!$data->flavorParamsOutput->sourceRemoteStorageProfileId) {
         clearstatcache();
         $fileSize = kFile::fileSize($data->destFileSyncLocalPath);
         kFile::moveFile($data->destFileSyncLocalPath, $sharedFile);
         // directory sizes may differ on different devices
         if (!file_exists($sharedFile) || is_file($sharedFile) && kFile::fileSize($sharedFile) != $fileSize) {
             KalturaLog::err("Error: moving file failed");
             die;
         }
         @chmod($sharedFile, 0777);
         $data->destFileSyncLocalPath = $this->translateLocalPath2Shared($sharedFile);
         if ($this->taskConfig->params->isRemoteOutput) {
             $data->destFileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($data->destFileSyncLocalPath);
             $job->status = KalturaBatchJobStatus::ALMOST_DONE;
             $job->message = "File ready for download";
         } elseif ($this->checkFileExists($data->destFileSyncLocalPath, $fileSize)) {
             $job->status = KalturaBatchJobStatus::FINISHED;
             $job->message = "File moved to shared";
         } else {
             $job->status = KalturaBatchJobStatus::RETRY;
             $job->message = "File not moved correctly";
         }
     } else {
         $job->status = KalturaBatchJobStatus::FINISHED;
         $job->message = "File is ready in the remote storage";
     }
     if ($data->logFileSyncLocalPath && file_exists($data->logFileSyncLocalPath)) {
         kFile::moveFile($data->logFileSyncLocalPath, "{$sharedFile}.log");
         @chmod("{$sharedFile}.log", 0777);
         $data->logFileSyncLocalPath = $this->translateLocalPath2Shared("{$sharedFile}.log");
         if ($this->taskConfig->params->isRemoteOutput) {
             // for remote conversion
             $data->logFileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($data->logFileSyncLocalPath);
         }
     } else {
         $data->logFileSyncLocalPath = '';
     }
     return $this->closeJob($job, null, null, $job->message, $job->status, $data);
 }