ruby - RubyZip: archiving process indication -


i adding tons of file archive looks this:

print "starting ..." zip::zipfile.open(myarchive, 'w') |zipfile|   my_tons_of_files.each |file|     print "adding #{file.filename} archive ... \r"     # ...   end   print "\n saving archive"   # !!! -> waiting 10-15 minutes   # want show percentage of completed job end 

after files added archive starts compress them (about 10-15 minutes).

how can indicate going on rubyzip gem (actually want show percentage current_file_number/total_files_count).

you can override zip::zipfile.commit:

require 'zip' require 'zip/zipfilesystem'  module zip class zipfile      def commit      return if ! commit_required?       on_success_replace(name) {         |tmpfile|         zipoutputstream.open(tmpfile) {           |zos|            total_files = @entryset.length           current_files = 1           @entryset.each |e|              puts "current file: #{current_files}, total files: #{total_files}"              current_files += 1              e.write_to_zip_output_stream(zos)           end           zos.comment = comment         }         true       }       initialize(name)     end  end end  print "starting ..." zip::zipfile.open(myarchive, 'w') |zipfile| 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -