taopaipai 0.1.0 → 0.1.1

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: 76f89d4892efbdd72aefc83bfd68819b30bfab61
4
- data.tar.gz: 807a87eea219ffe3dfbe0d3b64665c752aad8c8f
3
+ metadata.gz: 2d3bf9c7dc19abd4417da09654b0f2b689454138
4
+ data.tar.gz: 64b9d9859902601745b75cff4db4baead49e6650
5
5
  SHA512:
6
- metadata.gz: a998207c3dd4cf59d99f042e704f4ae64fb3e0a03d384b660bd0684be5c2c5b15a68a188ced48cf110efd84fe109c616b947525b0ab0e88ec6817c0ce2b5fc99
7
- data.tar.gz: 3665259d4c536930a17994913e9f3ef66c83f84baee45fa7f237852392d264df34ec39c56753b83a46700411c221bc4add5659d74c384a78459482e7f88f8b3b
6
+ metadata.gz: 9128ff6d1d550c7bc566f6ecdf032ee35597407972f0ba6556072fb20db45669a4f91e8a7c1bc8ee9469f5f862883d7add85a2b7268867ce352f98e980bf8698
7
+ data.tar.gz: a097553b8a64e2b4626fc95d283356bf695f6df22373efc922c8cf3da5c00df45d5d62b3e29c7fab9549582cfbf17b858f8add1330f4d1a8c341bd09bf229b28
data/lib/taopaipai/io.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Taopaipai
2
2
  class IO
3
+ MAX_WRITE_ATTEMPTS = 10
4
+
3
5
  def initialize(base_path)
4
6
  @base_path = base_path
5
7
  end
@@ -25,12 +27,14 @@ module Taopaipai
25
27
  end
26
28
 
27
29
  private
28
- def write_to_file(path, content, last_attempt = false)
30
+ def write_to_file(path, content, attempts = 1)
29
31
  begin
30
32
  File.open(relative(path), 'w'){|f| f.write(content) }
31
33
  rescue => e
32
- unless last_attempt
33
- write_to_file(path, content, true)
34
+ if attempts <= MAX_WRITE_ATTEMPTS
35
+ # Wait 10 ms before retry
36
+ sleep 0.01
37
+ write_to_file(path, content, attempts + 1)
34
38
  else
35
39
  raise e
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module Taopaipai
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taopaipai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jef Mathiot