Permalink
Browse files

Автоматическое определение числа ядер для размера очереди.

  • Loading branch information...
1 parent b0a2f93 commit 31d3fd30fe49accd7145f549d0ca6cb592bf3b0e @Tyralion Tyralion committed Apr 10, 2012
Showing with 4 additions and 2 deletions.
  1. +3 −1 lib/acts_as_files.rb
  2. +1 −1 lib/acts_as_files/multimedia/instance_methods.rb
View
4 lib/acts_as_files.rb
@@ -9,7 +9,9 @@ module ActsAsFiles
AR = defined?(ActiveRecord)
ID = (ActsAsFiles::MONGOID ? :_id : :id)
- CRAWLER = ::GirlFriday::Queue.new('image_crawler', :size => 5) do |arr|
+ CORES = `cat /proc/cpuinfo | grep processor | wc -l`.chop.to_i
+
+ CRAWLER = ::GirlFriday::Queue.new('image_crawler', :size => ::ActsAsFiles::CORES) do |arr|
(parent, mark, action) = arr
View
2 lib/acts_as_files/multimedia/instance_methods.rb
@@ -32,7 +32,7 @@ def image?
#
def file_mime_type
- (result, answer) = [`file --mime-type -b "#{self.path}"`.strip, $?]
+ (result, answer) = [`file --mime-type -b "#{self.path}"`.chomp.strip, $?]
answer.exitstatus == 0 ? result : nil
end # file_mime_type

0 comments on commit 31d3fd3

Please sign in to comment.