lib/rbbt/persist.rb in rbbt-util-5.14.3 vs lib/rbbt/persist.rb in rbbt-util-5.14.4
- old
+ new
@@ -130,11 +130,14 @@
raise $!
end
end
def self.save_file(path, type, content, lockfile = nil)
- return if content.nil?
+ if content.nil?
+ lockfile.unlock if lockfile and lockfile.locked?
+ return
+ end
case (type || :marshal).to_sym
when :nil
nil
when :boolean
@@ -290,11 +293,15 @@
rescue Exception
end
retry
rescue Exception
Log.medium "Error in persist: #{path}#{Open.exists?(path) ? Log.color(:red, " Erasing") : ""}"
- Log.exception $!
- FileUtils.rm path if Open.exists? path
+
+ begin
+ FileUtils.rm path
+ rescue
+ end if Open.exists? path
+
raise $!
end
end
def self.persist(name, type = nil, persist_options = {}, &block)