rabbit_swift 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 527be709e835fa8da3431235de1c117f3bbeb11c
4
- data.tar.gz: 95c6d1999fe6249eb0f97b9f4151048bd052714f
3
+ metadata.gz: 310e813c8e2dc70e79b4bf224cbcdd7d99907afd
4
+ data.tar.gz: da83c59fb0ac14e5d9c96e8d4f9086187c96af48
5
5
  SHA512:
6
- metadata.gz: 556fea58858f6a5297da232d91e8640bac5fe8a5a6e1694d7fd3d2e1818843d6cb32b7d595e49a9c116ffb822a34954ba0a8c62d15ecc26d3ee63a1e4e215083
7
- data.tar.gz: c52235940362a4119f5ea09787e7cec13adfd964e256dab4de56274ed07e490fddfd437b1c7f93de9e78b57e848b780f7f087eaa296d5efa301295587a9c3411
6
+ metadata.gz: 3c827b038e9d582d1c2474ddf1d700d2804baaf758f78e0fb830b6c0b90491811ea155d98f8cb75b419b6516ede821ec7ceeb57d41d54fc5fcfcdafe24f94e74
7
+ data.tar.gz: ec60ed8e2800ed2898cd18ea2b240bcbd22019a4b556e6783c0dff5bc6e5099ef2cadb76dd008fab209fa339dafaac321d5f708f17818400efd1696e03650703
data/README.md CHANGED
@@ -63,10 +63,9 @@ Or install it yourself as:
63
63
  #### SLO Upload Flow
64
64
  1. split file
65
65
  2. upload split files
66
- 3. create manifest file
66
+ 3. create manifest json (to memory)
67
67
  4. upload manifest file
68
- 5. delete split files
69
- 6. delete manifest file
68
+ 5. delete split file
70
69
 
71
70
  ### bin utils
72
71
 
data/RELEASE.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # リリース履歴
2
2
 
3
+ ## 0.3.7
4
+
5
+ (2015/02/22)
6
+
7
+ Check Original meta md5sum
8
+
3
9
  ## 0.3.6
4
10
 
5
11
  (2015/02/21)
data/bin/get_object.rb CHANGED
@@ -44,6 +44,9 @@ response.each do |k, v|
44
44
  end
45
45
 
46
46
  original_file_md5 = response['Etag']
47
+ if is_large_object && response.has_key?(RabbitSwift::LargeObject::StaticLargeObject::ORIGINAL_MD5SUM_META_NAME)
48
+ original_file_md5 = response[RabbitSwift::LargeObject::StaticLargeObject::ORIGINAL_MD5SUM_META_NAME]
49
+ end
47
50
 
48
51
  save_file_path = rabbit_swift_client.get_object(token, url, dest_path)
49
52
  puts save_file_path
@@ -63,8 +66,8 @@ else
63
66
  end
64
67
 
65
68
 
66
- #when SLO don't check md5. check file size
67
- if (!is_large_object)
69
+ #when SLO don't check md5.
70
+ if (!is_large_object || response.has_key?(RabbitSwift::LargeObject::StaticLargeObject::ORIGINAL_MD5SUM_META_NAME))
68
71
  save_file_md5 = Digest::MD5.file(save_file_path).to_s
69
72
  puts original_file_md5 + ' --> original_file_md5'
70
73
  puts save_file_md5 + ' --> save_file_md5'
@@ -192,7 +192,7 @@ module RabbitSwift
192
192
  @res.status
193
193
  end
194
194
 
195
- def upload_manifest(token, end_point, dest_container,input_file_path, manifest_json)
195
+ def upload_manifest(token, end_point, dest_container,input_file_path, manifest_json, original_file_md5sum)
196
196
  #相対パスがきた時のために絶対パスに変換
197
197
  path_name_obj = Pathname.new(input_file_path);
198
198
  file_path = path_name_obj.expand_path.to_s
@@ -208,7 +208,8 @@ module RabbitSwift
208
208
  {'X-Auth-Token' => token,
209
209
  'X-Object-Manifest' => manifest_path+'_',
210
210
  'X-STATIC-LARGE-OBJECT' => true,
211
- 'Content-Type' => 'application/json'
211
+ 'Content-Type' => 'application/json',
212
+ LargeObject::StaticLargeObject::ORIGINAL_MD5SUM_META_NAME => original_file_md5sum
212
213
  }
213
214
  http_client = HTTPClient.new
214
215
  url = URI.parse(URI.encode(target_url + '?multipart-manifest=put'))
@@ -1,9 +1,10 @@
1
1
  require 'rabbit_swift'
2
+ require 'digest/md5'
2
3
 
3
4
  module RabbitSwift::LargeObject
4
5
  class Slo_client
5
6
 
6
- attr_accessor :rabbit_swift_client, :src_path, :dest_path, :original_dest_path, :slo_option
7
+ attr_accessor :rabbit_swift_client, :src_path, :dest_path, :original_dest_path, :slo_option, :original_file_md5sum
7
8
 
8
9
  def initialize(rabbit_swift_client, src_path, dest_path, slo_option = {})
9
10
  @rabbit_swift_client = rabbit_swift_client
@@ -17,6 +18,7 @@ module RabbitSwift::LargeObject
17
18
  end
18
19
 
19
20
  def upload
21
+ original_file_md5sum = Digest::MD5.file(src_path).to_s
20
22
  if @slo_option.has_key?('limit_file_size')
21
23
  slo = RabbitSwift::LargeObject::StaticLargeObject.new(src_path, dest_path, limit_file_size: @slo_option['limit_file_size'])
22
24
  else
@@ -46,7 +48,7 @@ module RabbitSwift::LargeObject
46
48
 
47
49
  puts "dest_path->" + dest_path
48
50
  #マニフェストをアップロード
49
- rabbit_swift_client.upload_manifest(token, dest_path, @original_dest_path, @src_path, manifest_json)
51
+ rabbit_swift_client.upload_manifest(token, dest_path, @original_dest_path, @src_path, manifest_json, original_file_md5sum)
50
52
 
51
53
  #分割したファイルを削除
52
54
  rabbit_file_split.delete_all
@@ -6,6 +6,7 @@ module RabbitSwift::LargeObject
6
6
  class StaticLargeObject
7
7
 
8
8
  LIMIT_FILE_SIZE = 5368709120;
9
+ ORIGINAL_MD5SUM_META_NAME = 'X-Object-Meta-Original-File-Md5sum'
9
10
 
10
11
  # 参考 http://blog.bit-isle.jp/bird/2013/06/35
11
12
  # Swift Server SLO https://github.com/openstack/swift/blob/7a9a0e14b1c6a8f51454379beac95cd594a4193b/swift/common/middleware/slo.py
@@ -1,3 +1,3 @@
1
1
  module RabbitSwift
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_swift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - AKB428