fog-aliyun 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 376e9d625d0f891e03da5fa24434bf5788e37a8c4a376a68c36e0491ec7db99e
4
- data.tar.gz: 9aa48ef8f48fedfdbb039396f6541684454a99ab596da88aeb69080dbc683c30
3
+ metadata.gz: 71f324e607c567e9377a324698f35edd82667312c28fce1d3d8dc2e7e771af19
4
+ data.tar.gz: 608ea19f6289e5fc3e6ab8642f1326b7b88cb81639853b91f98be251923633e5
5
5
  SHA512:
6
- metadata.gz: fd565acfa305709b20e24775a94ca17eb3dd12f2151361fca6a0cf40fa43993108b18d02b6d9fe6ecef86fabc7a64204710c4efe6650c62d0c94c90002ebcf42
7
- data.tar.gz: 641a2b4a09e558c29851bebd8ec089f6fd872f6c568f3076ca74c6d7909adb3b99d0fe32bfa7e05059e45630fc0f6422a5a97945b3b719f16e60b4cbbe874287
6
+ metadata.gz: 80f63cc617a5e1d1758955342ae252c94e89dbb429575ad8da406100d3dd56a446dd34cbfa896be2c8908e7fd118e7cfb6e87f648def81a52b812c1f72832be8
7
+ data.tar.gz: 1da3cd3a1a3d8bc19d2290fdce54f2e9efe1e26849a93a8a5a2b7310f3303c46e1550d0e445cd316b1a7a8fdd5c39f2a07f79a19351e3857b02bd6cf117df37d
@@ -31,13 +31,16 @@ module Fog
31
31
  # If key does not contain /, if bucket, return '', else return an existed or a new one directory;
32
32
  def get(key, options = {})
33
33
  if !key.nil? && key != '' && key != '.'
34
+ key = key.chomp('/')
34
35
  if key.include? '/'
35
36
  dir = key + '/'
36
37
  ret = service.head_object(dir, options)
37
38
  new(key: key) if ret.data[:status] == 200
38
39
  else
39
40
  data = service.get_bucket(key)
40
- if data[:status] == 404
41
+ puts "[DEBUG] Getting the bucket named with #{key}..."
42
+ puts data
43
+ if data.class == Hash && data.key?('Code') && !data['Code'].nil? && !data['Code'].empty?
41
44
  dir = key + '/'
42
45
  ret = service.head_object(dir, options)
43
46
  new(key: key) if ret.data[:status] == 200
@@ -6,10 +6,18 @@ module Fog
6
6
  class Real
7
7
  def get_bucket(bucket)
8
8
  location = get_bucket_location(bucket)
9
+ # If there is an error, it will return a Hash with error code, host id and others
10
+ # If can not get a valid location, will return one using region
11
+ if location.class == Hash && location.key?('HostId')
12
+ value = location['HostId']
13
+ location = value[0].split('.')[1]
14
+ else
15
+ location = 'oss-' + @aliyun_region_id
16
+ end
9
17
  endpoint = 'http://' + location + '.aliyuncs.com'
10
18
  resource = bucket + '/'
11
19
  ret = request(
12
- expects: [200, 203],
20
+ expects: [200, 203, 404],
13
21
  method: 'GET',
14
22
  bucket: bucket,
15
23
  resource: resource,
@@ -23,7 +31,7 @@ module Fog
23
31
  attribute = '?location'
24
32
  resource = bucket + '/' + attribute
25
33
  ret = request(
26
- expects: [200, 203],
34
+ expects: [200, 203, 403, 404],
27
35
  method: 'GET',
28
36
  path: attribute,
29
37
  bucket: bucket,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fog
4
4
  module Aliyun
5
- VERSION = '0.3.6'
5
+ VERSION = '0.3.7'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aliyun
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
  - Qinsi Deng, Jianxun Li, Jane Han
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2020-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler