rbbt-util 5.5.8 → 5.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/rbbt/persist.rb +20 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmM0NTFmMmQwODc0NDc3NTRjNTI5ODY3YjZiZTJkMDZmMTZkYTY3MA==
4
+ YzZjOWMzZjRhNWIyMmRhMjc1MjM1NGU3NGNhNWJiMWU3MmE4ZDExYw==
5
5
  data.tar.gz: !binary |-
6
- Nzg3OTRjZjU3NDljZWY5MDlhOGI3OGQxNDBiMTc1ODhmZmI5OGQ1MQ==
6
+ MzhlY2RmNWYxNDk4ZTNmMTk2ZTU3NTYyN2JhNmY4YmJiMzUxYzQ3MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjViN2E5ZDJjNTM3MjJkZjRlOWNhY2RhYjhiYjZkMTUzZWZjMzA1MmViMzc3
10
- Nzc4ZWFkNjYzNDc0ZjVkMjNmMmEyZmQ5MWZhNDIwY2IxNzA2MzE4ZDEwNmRm
11
- NzA3YjE3YjQ1ZDE3ODMxMjRmZjViZTA1NTFiMGEzMmFhN2E0MTE=
9
+ ZDBmM2RhZWI3MTc3Nzc5OGQ5NGIxN2I0ZTg4ZDkyNmRlMmY5MzhjODU1YzU3
10
+ NWM4MjlmZmM5NGZiMjEzNjUyZWE0NjJkMDQ1NTEzNjJjNjVmMTcxOThiMTY5
11
+ YTQ0ZDNmYzJhOTQ3MzJmYWRkNDIwMDYxMmE4ZDZlN2ZlMTYyMzI=
12
12
  data.tar.gz: !binary |-
13
- ZWUzMDU0M2I1ZTU2YmY2M2Y4ZjAzZjRiMGNiM2RlOGEzNTAxYTZhODNkZDll
14
- YWFmMzI1OWRjNDNjYWExMzA0MTMxMTY0MjcxYzc1YzUyZGI0YTM0OGNlYWJh
15
- MzVhZTI0Zjc3Njg1NmQxNGU2OTM3ZmQ1NzBmZGJlOThlMDZkODE=
13
+ N2QzYWEyNDAxYWRmOGIyMDM5YmU1YTAxZDQ3ZDA5Mzg5Njk4OTY1Zjc4Y2U4
14
+ ZDAwZjFiOWVlYzg1NzNkNDk2NzEzNzdkMjVjN2U2ZTk4MjQzMzY0MzRjMmY0
15
+ YzhkYmJiZDE3OGE0NmI0NTU4NjVmYzNhN2YwYzZmZDhkZDc4Y2E=
data/lib/rbbt/persist.rb CHANGED
@@ -14,6 +14,12 @@ module Persist
14
14
  def self.cachedir
15
15
  @cachedir ||= Rbbt.var.cache.persistence
16
16
  end
17
+
18
+ attr_accessor :lock_dir
19
+
20
+ def lock_dir
21
+ @lock_dir ||= Rbbt.tmp.tsv_open_locks.find
22
+ end
17
23
  end
18
24
 
19
25
  MEMORY = {} unless defined? MEMORY
@@ -256,16 +262,24 @@ module Persist
256
262
  Log.low "Persist up-to-date: #{ path } - #{persist_options.inspect[0..100]}"
257
263
  return nil if persist_options[:no_load]
258
264
  return load_file(path, type)
259
- else
260
- Log.medium "Persist create: #{ path } - #{persist_options.inspect[0..100]}"
261
265
  end
262
266
 
263
267
  begin
264
- res = yield
265
- Misc.lock(path) do
266
- save_file(path, type, res)
268
+ lock_filename = Persist.persistence_path(path + '.persist', {:dir => Persist.lock_dir})
269
+ Misc.lock lock_filename do
270
+ if is_persisted?(path, persist_options)
271
+ Log.low "Persist up-to-date: #{ path } - #{persist_options.inspect[0..100]}"
272
+ return nil if persist_options[:no_load]
273
+ return load_file(path, type)
274
+ end
275
+
276
+ Log.medium "Persist create: #{ path } - #{persist_options.inspect[0..100]}"
277
+ res = yield
278
+ Misc.lock(path) do
279
+ save_file(path, type, res)
280
+ end
281
+ res
267
282
  end
268
- res
269
283
  rescue
270
284
  Log.high "Error in persist. #{Open.exists?(path) ? "Erasing '#{ path }'" : ""}"
271
285
  FileUtils.rm path if Open.exists? path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.8
4
+ version: 5.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2013-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake