Skip to content

Commit

Permalink
'Files' entry type causing error #87
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Apr 3, 2018
1 parent 649cc83 commit 8dd19b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/redmine_xapian/search_strategies/xapian_search.rb
Expand Up @@ -121,7 +121,7 @@ def process_attachment(projects, dochash, user)
Rails.logger.debug "Attachment's docattach not nil..: #{attachment}"
if attachment.container
Rails.logger.debug 'Adding attachment'
project = attachment.container.project
project = attachment.project
container_type = attachment[:container_type]
container_permission = SearchStrategies::ContainerTypeHelper.to_permission(container_type)
can_view_container = user.allowed_to?(container_permission, project)
Expand All @@ -136,7 +136,7 @@ def process_attachment(projects, dochash, user)
projects = [] << projects if projects.is_a?(Project)
project_ids = projects.collect(&:id) if projects

if allowed && (project_ids.blank? || (project_ids.include?(attachment.container.project.id)))
if allowed && (project_ids.blank? || (attachment.project && project_ids.include?(attachment.project.id)))
Redmine::Search.cache_store.write("Attachment-#{attachment.id}",
dochash[:sample].force_encoding('UTF-8')) if dochash[:sample]
return attachment
Expand Down

0 comments on commit 8dd19b5

Please sign in to comment.