Guest User

Untitled

a guest
Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. diff --git a/lib/rhosync/jobs/bulk_data_job.rb b/lib/rhosync/jobs/bulk_data_job.rb
  2. old mode 100755
  3. new mode 100644
  4. index 2e7fae5..43ef519
  5. --- a/lib/rhosync/jobs/bulk_data_job.rb
  6. +++ b/lib/rhosync/jobs/bulk_data_job.rb
  7. @@ -1,5 +1,6 @@
  8. require 'sqlite3'
  9. require 'zip/zip'
  10. +require 'zlib'
  11.  
  12. module Rhosync
  13. module BulkDataJob
  14. @@ -153,7 +154,10 @@ module Rhosync
  15. end
  16. populate_sources_table(db,sources_refs)
  17. db.execute_batch(File.open(index,'r').read)
  18. + db.execute_batch( "VACUUM;");
  19. + db.close
  20. compress("#{bulk_data.dbfile}.rzip",bulk_data.dbfile)
  21. + gzip_compress("#{bulk_data.dbfile}.gzip",bulk_data.dbfile)
  22. end
  23.  
  24. def self.create_hsql_data_file(bulk_data,ts)
  25. @@ -166,6 +170,7 @@ module Rhosync
  26. 'com.rhomobile.hsqldata.HsqlData',
  27. dbfile, hsql_file
  28. )
  29. + gzip_compress("#{hsql_file}.data.gzip","#{hsql_file}.data")
  30. end
  31.  
  32. def self.get_file_args(bulk_data_name,ts)
  33. @@ -180,5 +185,16 @@ module Rhosync
  34. zipfile.add(URI.escape(File.basename(file)),file)
  35. end
  36. end
  37. +
  38. + def self.gzip_compress(archive,file)
  39. + data = File.new(file, "rb")
  40. + File.open(archive, 'wb') do |f|
  41. + gz = Zlib::GzipWriter.new(f)
  42. + gz.write data.read
  43. + gz.close
  44. + end
  45. + data.close
  46. + end
  47. +
  48. end
  49. end
Add Comment
Please, Sign In to add comment