lib/rbbt/persist.rb in rbbt-util-5.7.0 vs lib/rbbt/persist.rb in rbbt-util-5.8.0
- old
+ new
@@ -274,12 +274,18 @@
end
Log.medium "Persist create: #{ path } - #{persist_options.inspect[0..100]}"
res = yield
- Misc.lock(path) do
- save_file(path, type, res)
+ if res.nil?
+ res = load_file(path) unless persist_options[:no_load]
+ else
+ Misc.lock(path) do
+ save_file(path, type, res)
+ end
end
+
+ return path if persist_options[:no_load]
res
end
rescue
Log.high "Error in persist. #{Open.exists?(path) ? "Erasing '#{ path }'" : ""}"