lib/rocket_job/dirmon_entry.rb in rocketjob-5.4.1 vs lib/rocket_job/dirmon_entry.rb in rocketjob-6.0.0.rc1

- old
+ new

@@ -55,24 +55,16 @@ field :archive_directory, type: String, default: default_archive_directory # If this DirmonEntry is in the failed state, exception contains the cause embeds_one :exception, class_name: "RocketJob::JobException" - # The maximum number of files that should ever match during a single poll of the pattern. # - # Too many files could be as a result of an invalid pattern specification. - # Exceeding this number will result in an exception being logged in a failed Dirmon instance. - # Dirmon processing will continue with new instances. - # TODO: Implement max_hits - # field :max_hits, type: Integer, default: 100 - - # # Read-only attributes # # Current state, as set by the state machine. Do not modify directly. - field :state, type: Symbol, default: :pending + field :state, type: Mongoid::StringifiedSymbol, default: :pending # Unique index on pattern to help prevent two entries from scanning the same files index({pattern: 1}, background: true, unique: true) before_validation :strip_whitespace @@ -238,20 +230,20 @@ job = RocketJob::Jobs::UploadFileJob.create!( job_class_name: job_class_name, properties: properties, description: "#{name}: #{iopath.basename}", - upload_file_name: archive_path.to_s, + upload_file_name: archive_path, original_file_name: iopath.to_s, job_id: job_id ) logger.info( message: "Created RocketJob::Jobs::UploadFileJob", payload: { dirmon_entry_name: name, - upload_file_name: archive_path.to_s, + upload_file_name: archive_path, original_file_name: iopath.to_s, job_class_name: job_class_name, job_id: job_id.to_s, upload_job_id: job.id.to_s } @@ -293,10 +285,28 @@ return unless klass properties.each_pair do |k, _v| next if klass.public_method_defined?("#{k}=".to_sym) - errors.add(:properties, "Unknown Property: Attempted to set a value for #{k.inspect} which is not allowed on the job #{job_class_name}") + if %i[output_categories input_categories].include?(k) + category_class = k == :input_categories ? RocketJob::Category::Input : RocketJob::Category::Output + properties[k].each do |category| + category.each_pair do |key, _value| + next if category_class.public_method_defined?("#{key}=".to_sym) + + errors.add( + :properties, + "Unknown Property in #{k}: Attempted to set a value for #{key}.#{k} which is not allowed on the job #{job_class_name}" + ) + end + end + next + end + + errors.add( + :properties, + "Unknown Property: Attempted to set a value for #{k.inspect} which is not allowed on the job #{job_class_name}" + ) end end end end