lib/rbbt/persist.rb in rbbt-util-5.14.0 vs lib/rbbt/persist.rb in rbbt-util-5.14.1
- old
+ new
@@ -130,11 +130,10 @@
raise $!
end
end
def self.save_file(path, type, content, lockfile = nil)
-
return if content.nil?
case (type || :marshal).to_sym
when :nil
nil
@@ -143,11 +142,11 @@
when :fwt
content.file.seek 0
Misc.sensiblewrite(path, content.file.read, :lock => lockfile)
when :tsv
content = content.to_s if TSV === content
- Misc.sensiblewrite(path, content)
+ Misc.sensiblewrite(path, content, :lock => lockfile)
when :annotations
Misc.sensiblewrite(path, Annotated.tsv(content, :all).to_s, :lock => lockfile)
when :string, :text
Misc.sensiblewrite(path, content, :lock => lockfile)
when :binary
@@ -217,12 +216,12 @@
stream = res if IO === res
stream = res.stream if res.respond_to? :stream
if stream
if persist_options[:no_load] == :stream
- res = tee_stream(stream, path, type, stream.respond_to?(:callback)? stream.callback : nil, stream.respond_to?(:abort_callback)? stream.abort_callback : nil)
- res.lockfile = lockfile
+ res = tee_stream(stream, path, type, stream.respond_to?(:callback)? stream.callback : nil, stream.respond_to?(:abort_callback)? stream.abort_callback : nil, lockfile)
+ #res.lockfile = lockfile
raise KeepLocked.new res
else
stream = res.get_stream if res.respond_to? :get_stream
begin
@@ -263,10 +262,9 @@
lock_filename = Persist.persistence_path(path + '.persist', {:dir => Persist.lock_dir})
begin
lock_options = Misc.pull_keys persist_options, :lock
lock_options = lock_options[:lock] if Hash === lock_options[:lock]
Misc.lock lock_filename, lock_options do |lockfile|
-
Misc.insist do
if is_persisted?(path, persist_options)
Log.low "Persist up-to-date (suddenly): #{ path } - #{Misc.fingerprint persist_options}"
return path if persist_options[:no_load]
return load_file(path, type)