myreplicator 1.1.47 → 1.1.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,7 +23,7 @@ module Myreplicator
23
23
 
24
24
  prepare metadata
25
25
 
26
- if @export_obj.export_type? == :new && load_to == "mysql"
26
+ if @export_obj.export_type? == :new || load_to == "mysql"
27
27
  on_failure_state_trans(metadata, "new") # If failed, go back to new
28
28
  on_export_success(metadata)
29
29
  initial_export metadata
@@ -96,7 +96,7 @@ module Myreplicator
96
96
  :filepath => filepath,
97
97
  :table => @export_obj.table_name)
98
98
  end
99
-
99
+ puts cmd
100
100
  return cmd
101
101
  end
102
102
 
@@ -36,7 +36,7 @@ module Myreplicator
36
36
  # cmd += "--tab=#{options[:filepath]} "
37
37
  # cmd += "--fields-enclosed-by=\'\"\' "
38
38
  # cmd += "--fields-escaped-by=\'\\\\\' "
39
-
39
+ puts cmd
40
40
  return cmd
41
41
  end
42
42
 
@@ -208,16 +208,29 @@ module Myreplicator
208
208
  # Creates table and loads data
209
209
  ##
210
210
  def self.initial_load metadata
211
- exp = Export.find(metadata.export_id)
211
+ exp = Myreplicator::Export.find(metadata.export_id)
212
212
  #Kernel.p "===== unzip ====="
213
213
  #Loader.unzip(metadata.filename)
214
214
  #metadata.zipped = false
215
+ filename = metadata.filename
216
+ if filename.split('.').last == 'gz'
217
+ filepath = metadata.destination_filepath(tmp_dir)
218
+ cmd = "gunzip #{filepath}"
219
+ system(cmd)
220
+ unzip_file = File.join(tmp_dir, filename.split('.')[0..-2].join('.'))
221
+ cmd = Myreplicator::ImportSql.initial_load(:db => exp.destination_schema,
222
+ :filepath => unzip_file.to_s)
223
+ puts cmd
224
+ result = `#{cmd} 2>&1` # execute
225
+ cmd2 = "gzip #{unzip_file.to_s}"
226
+ system(cmd2)
227
+ else
228
+ cmd = Myreplicator::ImportSql.initial_load(:db => exp.destination_schema,
229
+ :filepath => metadata.destination_filepath(tmp_dir))
230
+ puts cmd
231
+ result = `#{cmd} 2>&1` # execute
232
+ end
215
233
 
216
- cmd = ImportSql.initial_load(:db => exp.destination_schema,
217
- :filepath => metadata.destination_filepath(tmp_dir))
218
- puts cmd
219
-
220
- result = `#{cmd}` # execute
221
234
  unless result.nil?
222
235
  if result.size > 0
223
236
  raise Exceptions::LoaderError.new("Initial Load #{metadata.filename} Failed!\n#{result}")
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.47"
2
+ VERSION = "1.1.48"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myreplicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.47
4
+ version: 1.1.48
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-10 00:00:00.000000000 Z
12
+ date: 2013-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -352,7 +352,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
352
352
  version: '0'
353
353
  segments:
354
354
  - 0
355
- hash: 3374412953550352773
355
+ hash: 1263010410819463678
356
356
  required_rubygems_version: !ruby/object:Gem::Requirement
357
357
  none: false
358
358
  requirements:
@@ -361,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
361
  version: '0'
362
362
  segments:
363
363
  - 0
364
- hash: 3374412953550352773
364
+ hash: 1263010410819463678
365
365
  requirements: []
366
366
  rubyforge_project:
367
367
  rubygems_version: 1.8.24