defog 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 054ad554825391cd44ebbe930f1a12fd14276503
4
+ data.tar.gz: 42dc7f447f64000ebb8db63b7ddf0b2226840015
5
+ SHA512:
6
+ metadata.gz: c4104287d84dfc9df6def6fc0566d2d04516002b564b3e61f1d78a6172ee6f2d67dcc4bec3d3812f4abdc9e8bec38f2c2781704b60374e02c561e9e8eadbab05
7
+ data.tar.gz: a8fe01d1cad058a1315b8c3151daf9b39c068e3738524a520b231e7721b2e6189293c2001e8cea5eaabe31b96924e854e76e99bdbaea528f2d35b4860da51d8a
data/README.md CHANGED
@@ -253,7 +253,7 @@ plus appropriate rspec examples.)
253
253
  ## History
254
254
 
255
255
  Release Notes:
256
-
256
+ * 0.9.2 - Bug fix: don't fail when measuring cache if file gets deleted by another process (more robust)
257
257
  * 0.9.1 - Bug fix: don't fail when measuring cache if file gets deleted by another process
258
258
  * 0.9.0 - Expose Handle#md5_hash
259
259
  * 0.8.0 - Include prefix in proxy_path (thus allowing cache sharing)
@@ -267,3 +267,7 @@ Release Notes:
267
267
  ## Copyright
268
268
 
269
269
  Released under the MIT License. See LICENSE for details.
270
+
271
+
272
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ronen/defog/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
273
+
data/lib/defog/proxy.rb CHANGED
@@ -194,13 +194,7 @@ module Defog
194
194
  # find available space (not counting current proxy)
195
195
  available = max_cache_size
196
196
  proxy_root.find { |path|
197
- available -= begin
198
- path.size
199
- rescue Errno::ENOENT
200
- # some other process has snuck in and deleted the
201
- # file since the path.file? check. has happened...
202
- 0
203
- end if path.file? and path != proxy_path
197
+ available -= pathTry(path, :size) if path.file? and path != proxy_path
204
198
  }
205
199
  return if available >= want_size
206
200
 
@@ -213,7 +207,7 @@ module Defog
213
207
 
214
208
  # take candidates in LRU order until that would be enough space
215
209
  would_free = 0
216
- candidates = Set.new(candidates.sort_by(&:atime).take_while{|path| (would_free < space_needed).tap{|condition| would_free += path.size}})
210
+ candidates = Set.new(candidates.sort_by(&:atime).take_while{|path| (would_free < space_needed).tap{|condition| would_free += pathTry(path, :size)}})
217
211
 
218
212
  # still not enough...?
219
213
  raise Error::CacheFull, "No room in cache for #{proxy_path.relative_path_from(proxy_root)}: size=#{want_size} available=#{available} can_free=#{would_free} (max_cache_size=#{max_cache_size})" if would_free < space_needed
@@ -222,23 +216,29 @@ module Defog
222
216
  # chunk. So take another pass, eliminating files that aren't needed.
223
217
  # Do this in reverse size order, since we want to keep big files in
224
218
  # the cache if possible since they're most expensive to replace.
225
- candidates.sort_by(&:size).reverse.each do |path|
226
- if (would_free - path.size) > space_needed
219
+ size = Hash.new { |h, path| h[path] = pathTry(path, :size) }
220
+ candidates.sort_by{|path| size[path]}.reverse.each do |path|
221
+ if (would_free - size[path]) > space_needed
227
222
  candidates.delete path
228
- would_free -= path.size
223
+ would_free -= size[path]
229
224
  end
230
225
  end
231
226
 
232
227
  # free the remaining candidates
233
228
  candidates.each do |candidate|
234
- begin
235
- candidate.unlink
236
- rescue Errno::ENOENT
237
- # some other process has deleted the file while we were looking at it.
238
- # nothing to do.
239
- end
229
+ pathTry(candidate, :unlink)
240
230
  end
231
+ end
241
232
 
233
+ # try a method on a Pathname without failing if the file doesn't exist
234
+ # (which could happen if some other process sneaks in and deletes the
235
+ # file after we found it).
236
+ def pathTry(path, method)
237
+ begin
238
+ path.send method
239
+ rescue Errno::ENOENT
240
+ 0
241
+ end
242
242
  end
243
243
 
244
244
  end
data/lib/defog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Defog
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
data/spec/proxy_spec.rb CHANGED
@@ -167,13 +167,20 @@ shared_examples "a proxy" do |args|
167
167
  other_proxy_path("c").should_not be_exist
168
168
  end
169
169
 
170
- it "should not fail size check when proxies get deleted by another process" do
171
- create_other_proxy("a", 10)
172
- create_other_proxy("b", 30)
173
- create_other_proxy("c", 40)
174
- create_remote("x" * 80)
175
- Pathname.any_instance.should_receive(:size).and_raise Errno::ENOENT
176
- expect { @proxy.file(key, "r") do end }.to_not raise_error(Errno::ENOENT)
170
+ [0, 3, 6].each do |sizect|
171
+ it "should not fail size check #{sizect} when proxies get deleted by another process" do
172
+ create_other_proxy("a", 30)
173
+ create_other_proxy("b", 30)
174
+ create_other_proxy("c", 30)
175
+ create_remote("x" * 80)
176
+ z = 0
177
+ Pathname.any_instance.stub(:size) { |path|
178
+ raise Errno::ENOENT if z == sizect
179
+ z += 1
180
+ 30
181
+ }
182
+ expect { @proxy.file(key, "r") do end }.to_not raise_error(Errno::ENOENT)
183
+ end
177
184
  end
178
185
 
179
186
  it "should not fail unlinking when proxies get deleted by another process" do
metadata CHANGED
@@ -1,142 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
5
- prerelease:
4
+ version: 0.9.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - ronen barzel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-10 00:00:00.000000000 Z
11
+ date: 2014-03-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fog
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: hash_keyword_args
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fastandand
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdoc
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: simplecov
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: simplecov-gem-adapter
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  description: Wrapper to fog gem, proxying access to cloud files as local files.
@@ -168,27 +151,26 @@ files:
168
151
  - spec/support/helpers.rb
169
152
  homepage: http://github.com/ronen/defog
170
153
  licenses: []
154
+ metadata: {}
171
155
  post_install_message:
172
156
  rdoc_options: []
173
157
  require_paths:
174
158
  - lib
175
159
  required_ruby_version: !ruby/object:Gem::Requirement
176
- none: false
177
160
  requirements:
178
- - - ! '>='
161
+ - - '>='
179
162
  - !ruby/object:Gem::Version
180
163
  version: '0'
181
164
  required_rubygems_version: !ruby/object:Gem::Requirement
182
- none: false
183
165
  requirements:
184
- - - ! '>='
166
+ - - '>='
185
167
  - !ruby/object:Gem::Version
186
168
  version: '0'
187
169
  requirements: []
188
170
  rubyforge_project:
189
- rubygems_version: 1.8.25
171
+ rubygems_version: 2.0.3
190
172
  signing_key:
191
- specification_version: 3
173
+ specification_version: 4
192
174
  summary: Wrapper to fog gem, proxying access to cloud files as local files. Access
193
175
  can be read-only (local cache), write-only (upload), or read-write (mirror)
194
176
  test_files:
@@ -197,4 +179,3 @@ test_files:
197
179
  - spec/proxy_spec.rb
198
180
  - spec/spec_helper.rb
199
181
  - spec/support/helpers.rb
200
- has_rdoc: