lib/rocket_job/dirmon_entry.rb in rocketjob-3.3.0 vs lib/rocket_job/dirmon_entry.rb in rocketjob-3.3.1

- old
+ new

@@ -185,19 +185,11 @@ # Example no dirmon entries: # RocketJob::Job.counts_by_state # # => {} def self.counts_by_state counts = {} - collection.aggregate([ - { - '$group' => { - _id: '$state', - count: {'$sum' => 1} - } - } - ] - ).each do |result| + collection.aggregate([{'$group' => {_id: '$state', count: {'$sum' => 1}}}]).each do |result| counts[result['_id'].to_sym] = result['count'] end counts end @@ -227,17 +219,23 @@ def each(&block) SemanticLogger.named_tagged(dirmon_entry: id.to_s) do # Case insensitive filename matching Pathname.glob(pattern, File::FNM_CASEFOLD).each do |pathname| next if pathname.directory? - pathname = pathname.realpath + pathname = begin + pathname.realpath + rescue Errno::ENOENT + logger.warn("Unable to expand the realpath for #{pathname.inspect}. Skipping file.") + next + end + file_name = pathname.to_s # Skip archive directories next if file_name.include?(self.class.default_archive_directory) # Security check? - if (whitelist_paths.size > 0) && whitelist_paths.none? { |whitepath| file_name.to_s.start_with?(whitepath) } + if (whitelist_paths.size > 0) && whitelist_paths.none? {|whitepath| file_name.to_s.start_with?(whitepath)} logger.error "Skipping file: #{file_name} since it is not in any of the whitelisted paths: #{whitelist_paths.join(', ')}" next end # File must be writable so it can be removed after processing