lib/rbbt/persist.rb in rbbt-util-5.18.1 vs lib/rbbt/persist.rb in rbbt-util-5.19.0
- old
+ new
@@ -25,10 +25,12 @@
MEMORY = {} unless defined? MEMORY
MAX_FILE_LENGTH = 150
def self.newer?(path, file)
return true if not Open.exists? file
+ path = path.find if Path === path
+ file = file.find if Path === file
return File.mtime(path) - File.mtime(file) if File.mtime(path) < File.mtime(file)
return false
end
def self.is_persisted?(path, persist_options = {})
@@ -80,11 +82,11 @@
filename = filename[0..MAX_FILE_LENGTH] << Misc.digest(filename[MAX_FILE_LENGTH+1..-1]) if filename.length > MAX_FILE_LENGTH + 10
options_md5 = Misc.hash2md5 clean_options
filename << ":" << options_md5 unless options_md5.empty?
- persistence_dir[filename].find
+ persistence_dir[filename]
end
TRUE_STRINGS = Set.new ["true", "True", "TRUE", "t", "T", "1", "yes", "Yes", "YES", "y", "Y", "ON", "on"] unless defined? TRUE_STRINGS
def self.load_file(path, type)
begin
@@ -331,14 +333,21 @@
else
persist_options[:update] ||= true if persist_options[:persist].to_s == "update"
other_options = Misc.process_options persist_options, :other
path = persistence_path(name, persist_options, other_options || {})
+ if ENV["RBBT_UPDATE_TSV_PERSIST"] == 'true' and name and Open.exists?(name)
+ persist_options[:check] ||= []
+ persist_options[:check] << name
+ else
+ check_options = {}
+ end
+
case
when type.to_sym == :memory
repo = persist_options[:repo] || Persist::MEMORY
- repo[path] ||= yield
+ repo[path.find] ||= yield
when (type.to_sym == :annotations and persist_options.include? :annotation_repo)
repo = persist_options[:annotation_repo]
@@ -417,10 +426,10 @@
entities
end
else
- persist_file(path, type, persist_options, &block)
+ persist_file(path.find, type, persist_options, &block)
end
end
end