protected function handleExistingDropFolderFile(KalturaDropFolderFile $dropFolderFile) { try { $fullPath = $this->dropFolder->path . '/' . $dropFolderFile->fileName; $lastModificationTime = $this->fileTransferMgr->modificationTime($fullPath); $fileSize = $this->fileTransferMgr->fileSize($fullPath); } catch (Exception $e) { $closedStatuses = array(KalturaDropFolderFileStatus::HANDLED, KalturaDropFolderFileStatus::PURGED, KalturaDropFolderFileStatus::DELETED); //In cases drop folder is not configured with auto delete we want to verify that the status file is not in one of the closed statuses so //we won't update it to error status if (!in_array($dropFolderFile->status, $closedStatuses)) { //Currently "modificationTime" does not throw Exception since from php documentation not all servers support the ftp_mdtm feature KalturaLog::err('Failed to get modification time or file size for file [' . $fullPath . ']'); $this->handleFileError($dropFolderFile->id, KalturaDropFolderFileStatus::ERROR_HANDLING, KalturaDropFolderFileErrorCode::ERROR_READING_FILE, DropFolderPlugin::ERROR_READING_FILE_MESSAGE . '[' . $fullPath . ']', $e); } return false; } if ($dropFolderFile->status == KalturaDropFolderFileStatus::UPLOADING) { $this->handleUploadingDropFolderFile($dropFolderFile, $fileSize, $lastModificationTime); } else { KalturaLog::info('Last modification time [' . $lastModificationTime . '] known last modification time [' . $dropFolderFile->lastModificationTime . ']'); $isLastModificationTimeUpdated = $dropFolderFile->lastModificationTime && $dropFolderFile->lastModificationTime != '' && $lastModificationTime > $dropFolderFile->lastModificationTime; if ($isLastModificationTimeUpdated) { $this->handleFileAdded($dropFolderFile->fileName, $fileSize, $lastModificationTime); } else { $deleteTime = $dropFolderFile->updatedAt + $this->dropFolder->autoFileDeleteDays * 86400; if ($dropFolderFile->status == KalturaDropFolderFileStatus::HANDLED && $this->dropFolder->fileDeletePolicy != KalturaDropFolderFileDeletePolicy::MANUAL_DELETE && time() > $deleteTime || $dropFolderFile->status == KalturaDropFolderFileStatus::DELETED) { $this->purgeFile($dropFolderFile); } } } }
/** * Tests kFileTransferMgr->modificationTime() */ public function testModificationTime() { // TODO Auto-generated kFileTransferMgrTest->testModificationTime() $this->markTestIncomplete("modificationTime test not implemented"); $this->kFileTransferMgr->modificationTime(); }
/** * @param string $filePath * @return int last modification time for the given $filePath */ private function getModificationTime($filePath) { return $this->fileTransferMgr->modificationTime($filePath); }