Class: Pindo::TaskSystem::JPSUploadMediaTask
- Defined in:
- lib/pindo/module/task/model/jps/jps_upload_media_task.rb
Overview
JPS Media 上传任务上传图片、视频等 media 文件到 JPS 并关联到提交记录
支持两种模式:
-
指定模式:传入 file_paths 和 git_commit_id
-
自动模式:只传入 project_path,自动查找 JPSMedia/ 目录和 git HEAD 信息
Constant Summary collapse
- MEDIA_EXTENSIONS =
支持的媒体文件扩展名
%w[png jpg jpeg gif bmp webp mp4 mov avi mkv webm].freeze
Instance Attribute Summary collapse
-
#file_paths ⇒ Object
readonly
Returns the value of attribute file_paths.
-
#git_commit_desc ⇒ Object
readonly
Returns the value of attribute git_commit_desc.
-
#git_commit_id ⇒ Object
readonly
Returns the value of attribute git_commit_id.
-
#git_commit_time ⇒ Object
readonly
Returns the value of attribute git_commit_time.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#workflow_id ⇒ Object
readonly
Returns the value of attribute workflow_id.
Attributes inherited from JPSTask
#app_info_obj, #project_name, #workflow_info
Attributes inherited from PindoTask
#callbacks_setup, #context, #created_at, #data_dependencies, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #task_key, #task_manager, #type
Class Method Summary collapse
- .default_retry_count ⇒ Object
- .default_retry_delay ⇒ Object
-
.default_retry_mode ⇒ Object
Media 上传任务重试配置.
-
.task_key ⇒ Object
任务键.
Instance Method Summary collapse
-
#initialize(file_paths, options = {}) ⇒ JPSUploadMediaTask
constructor
初始化 Media 上传任务.
- #validate ⇒ Object
Methods inherited from JPSTask
Methods inherited from PindoTask
#before_retry, #cancel, #cancelled?, #check_cancelled!, #data_param, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #reset_for_retry, #retryable?, #running?, #should_retry?, task_type
Constructor Details
#initialize(file_paths, options = {}) ⇒ JPSUploadMediaTask
初始化 Media 上传任务
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 34 def initialize(file_paths, = {}) @file_paths = file_paths || [] # 要上传的文件路径列表 @git_commit_id = [:git_commit_id] # Git commit SHA @git_commit_time = [:git_commit_time] # Git commit 时间 @git_commit_desc = [:git_commit_desc] # Git commit 描述 @workflow_id = [:workflow_id] # 工作流ID @project_path = [:project_path] # 项目路径 # 设置任务优先级为 LOW,确保在其他任务之后执行 [:priority] ||= TaskPriority::LOW name = "上传 Media 附件" super(name, ) end |
Instance Attribute Details
#file_paths ⇒ Object (readonly)
Returns the value of attribute file_paths.
14 15 16 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 14 def file_paths @file_paths end |
#git_commit_desc ⇒ Object (readonly)
Returns the value of attribute git_commit_desc.
14 15 16 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 14 def git_commit_desc @git_commit_desc end |
#git_commit_id ⇒ Object (readonly)
Returns the value of attribute git_commit_id.
14 15 16 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 14 def git_commit_id @git_commit_id end |
#git_commit_time ⇒ Object (readonly)
Returns the value of attribute git_commit_time.
14 15 16 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 14 def git_commit_time @git_commit_time end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
15 16 17 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 15 def project_path @project_path end |
#workflow_id ⇒ Object (readonly)
Returns the value of attribute workflow_id.
15 16 17 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 15 def workflow_id @workflow_id end |
Class Method Details
.default_retry_count ⇒ Object
65 66 67 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 65 def self.default_retry_count 2 # Media 上传重试次数较少 end |
.default_retry_delay ⇒ Object
69 70 71 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 69 def self.default_retry_delay 5 # 延迟 5 秒 end |
.default_retry_mode ⇒ Object
Media 上传任务重试配置
61 62 63 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 61 def self.default_retry_mode RetryMode::DELAYED end |
.task_key ⇒ Object
任务键
21 22 23 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 21 def self.task_key :jps_upload_media end |
Instance Method Details
#validate ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/pindo/module/task/model/jps/jps_upload_media_task.rb', line 50 def validate # 验证 project_path(必需参数) unless @project_path && !@project_path.empty? && Dir.exist?(@project_path) @error = "缺少必需参数: project_path(项目路径)或路径不存在" return false end true end |