/** * @throws 404 */ private function getAttachedFileSize($id) { try { return $this->file_manager->getAttachedFileSize($id); } catch (FileNotFoundException $e) { throw new RestException(404); } }
private function checkFileIsTemporary($id) { if (!$this->file_manager->isFileIdTemporary($id)) { $this->raiseError(404); } }
private function checkFileIsTemporary($id) { if (!$this->file_manager->isFileIdTemporary($id)) { throw new RestException(404); } }
protected function createAttachmentForRest(Tracker_FileInfo $attachment, $file_info) { $path = $this->getRootPath(); if (!is_dir($path . '/thumbnails')) { mkdir($path . '/thumbnails', 0777, true); } $method = 'move_uploaded_file'; $tmp_name = $file_info['tmp_name']; if (isset($file_info['id'])) { $filename = $file_info['id']; $temporary = new Tracker_Artifact_Attachment_TemporaryFileManager($this->getCurrentUser(), $this->getTemporaryFileManagerDao(), $this->getFileInfoFactory()); if (!$temporary->exists($filename)) { $attachment->delete(); return false; } $method = 'rename'; $tmp_name = $temporary->getPath($filename); $temporary->removeTemporaryFileInDBByTemporaryName($filename); } return $this->moveAttachmentToFinalPlace($attachment, $method, $tmp_name); }
/** * @see Event::PROCCESS_SYSTEM_CHECK */ public function proccess_system_check(array $params) { $file_manager = new Tracker_Artifact_Attachment_TemporaryFileManager($this->getUserManager(), new Tracker_Artifact_Attachment_TemporaryFileManagerDao(), new Tracker_FileInfoFactory(new Tracker_FileInfoDao(), Tracker_FormElementFactory::instance(), Tracker_ArtifactFactory::instance()), new System_Command(), ForgeConfig::get('sys_file_deletion_delay')); $file_manager->purgeOldTemporaryFiles(); }