Skip to content

Commit 3009821

Browse files
safegards for old boutiques and misc minor corrections
1 parent 9fd290e commit 3009821

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

BrainPortal/app/models/tool_config.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,21 +625,21 @@ def self.register_descriptor(descriptor, tool_name, tool_version) #:nodoc:
625625
def self.registered_boutiques_descriptor(tool_name, tool_version) #:nodoc:
626626
@_descriptors_ ||= {}
627627
key = [ tool_name, tool_version ] # two strings
628-
@_descriptors_[key] = @_descriptors_[key]&.reload_if_file_timestamp_changed
628+
@_descriptors_[key] &&= @_descriptors_[key].try :reload_if_file_timestamp_changed # try to support old style boutiques
629629
@_descriptors_[key]
630630
end
631631

632632
def boutiques_descriptor
633+
path = boutiques_descriptor_path.presence
634+
return self.class.registered_boutiques_descriptor(self.tool.name, self.version_name) if ! path
635+
633636
if @_descriptor_
634-
@_descriptor_ = @_descriptor_.reload_if_file_timestamp_changed
637+
@_descriptor_ &&= @_descriptor_.try :reload_if_file_timestamp_changed
635638
key = [ self.tool.name, self.version_name ] # two strings
636639
@_descriptors_[key] = @_descriptor_
637640
return @_descriptor_
638641
end
639-
path = boutiques_descriptor_path.presence
640-
if ! path
641-
return self.class.registered_boutiques_descriptor(self.tool.name, self.version_name)
642-
end
642+
643643
path = Pathname.new(path)
644644
path = Pathname.new(CBRAIN::BoutiquesDescriptorsPlugins_Dir) + path if path.relative?
645645
@_descriptor_ = BoutiquesSupport::BoutiquesDescriptor.new_from_file(path)

BrainPortal/lib/boutiques_support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def self.new_from_file(path)
182182

183183
def reload_if_file_timestamp_changed()
184184
filepath = self.from_file
185-
return self if filepath.blank? || File.mtime(filepath) == self.mtime_of_file
185+
return self if filepath.blank? || (File.mtime(filepath) - self.mtime_of_file ).abs < 1
186186
self.class.new_from_file(filepath)
187187
end
188188

0 commit comments

Comments
 (0)