rufus-cloche 1.0.3 → 1.0.4

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.
@@ -2,6 +2,11 @@
2
2
  = rufus-cloche CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-cloche - 1.0.4 not yet released
6
+
7
+ - reinforce "gone detection again"
8
+
9
+
5
10
  == rufus-cloche - 1.0.3 released 2013/02/21
6
11
 
7
12
  - fix issue when putting a just deleted doc
data/TODO.txt CHANGED
@@ -9,4 +9,5 @@
9
9
  [o] work/msgs/.0/8811-2151883888-1260352977.0.json issue...
10
10
 
11
11
  [ ] LRU ?
12
+ [ ] do not lock for cloche#get ?
12
13
 
@@ -92,7 +92,7 @@ module Rufus
92
92
  ) if rev.class != Fixnum && rev.class != Bignum
93
93
 
94
94
  r =
95
- lock(rev == -1, type, key) do |file|
95
+ lock(rev == -1 ? :create : :write, type, key) do |file|
96
96
 
97
97
  cur = do_get(file)
98
98
 
@@ -111,7 +111,7 @@ module Rufus
111
111
  #
112
112
  def get(type, key)
113
113
 
114
- r = lock(false, type, key) { |f| do_get(f) }
114
+ r = lock(:read, type, key) { |f| do_get(f) }
115
115
 
116
116
  r == false ? nil : r
117
117
  end
@@ -136,7 +136,7 @@ module Rufus
136
136
  type, key = doc['type'], doc['_id']
137
137
 
138
138
  r =
139
- lock(false, type, key) do |f|
139
+ lock(:delete, type, key) do |f|
140
140
 
141
141
  cur = do_get(f)
142
142
 
@@ -287,7 +287,7 @@ module Rufus
287
287
  [ File.join(dir_for(type), subdir), "#{nkey}.json" ]
288
288
  end
289
289
 
290
- def lock(create, type, key, &block)
290
+ def lock(ltype, type, key, &block)
291
291
 
292
292
  @mutex.synchronize do
293
293
  begin
@@ -295,8 +295,8 @@ module Rufus
295
295
  d, f = path_for(type, key)
296
296
  fn = File.join(d, f)
297
297
 
298
- FileUtils.mkdir_p(d) if create && ( ! File.exist?(d))
299
- FileUtils.touch(fn) if create && ( ! File.exist?(fn))
298
+ FileUtils.mkdir_p(d) if ltype == :create && ( ! File.exist?(d))
299
+ FileUtils.touch(fn) if ltype == :create && ( ! File.exist?(fn))
300
300
 
301
301
  file = File.new(fn, 'r+') rescue nil
302
302
 
@@ -304,7 +304,10 @@ module Rufus
304
304
 
305
305
  file.flock(File::LOCK_EX) unless @nolock
306
306
 
307
- 7.times { return false unless File.exist?(fn) } unless create
307
+ if ltype == :write
308
+ Thread.pass
309
+ 21.times { return false unless File.exist?(fn) }
310
+ end
308
311
  #
309
312
  # We got the lock, but is the file still here?
310
313
  #
@@ -30,7 +30,7 @@ module Rufus
30
30
  #
31
31
  class Cloche
32
32
 
33
- VERSION = '1.0.3'
33
+ VERSION = '1.0.4'
34
34
  end
35
35
  end
36
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-cloche
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
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-02-20 00:00:00.000000000 Z
12
+ date: 2013-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rufus-json