Skip to content

Instantly share code, notes, and snippets.

@kalabiyau
Created October 26, 2011 08:49
Show Gist options
  • Save kalabiyau/1315815 to your computer and use it in GitHub Desktop.
Save kalabiyau/1315815 to your computer and use it in GitHub Desktop.
class Msgfile
MSGCONVERTER = "perl -w ~/bin/msgconvert.pl"
@path = Rails.root.join("tmp/docs").to_s
def self.convert_to_mime
Dir.chdir(@path)
fsnames = Dir[@path+"/*.msg"].map! {|f| escape_rus_filename(f)}.map!{|f| Rails.root.join(f).to_s }
fsgroups = fsnames.in_groups_of(6,false)
pids = fsgroups.map do |group|
group.map do |file|
@pid = Process.fork do
exec MSGCONVERTER << " #{file}"
end
end
end
pids.flatten.each { |pid| Process.waitpid(pid) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment