fixes modification during iteration
This commit is contained in:
parent
7a0a36c536
commit
004d66110d
@ -169,16 +169,16 @@ class DmsfQuery < Query
|
|||||||
order(order_option).
|
order(order_option).
|
||||||
limit(options[:limit]).
|
limit(options[:limit]).
|
||||||
offset(options[:offset]).to_a
|
offset(options[:offset]).to_a
|
||||||
items.each do |item|
|
items.delete_if do |item|
|
||||||
case item.type
|
case item.type
|
||||||
when 'folder'
|
when 'folder'
|
||||||
dmsf_folder = DmsfFolder.find_by(id: item.id)
|
dmsf_folder = DmsfFolder.find_by(id: item.id)
|
||||||
if dmsf_folder && (!DmsfFolder.permissions?(dmsf_folder, false))
|
if dmsf_folder && (!DmsfFolder.permissions?(dmsf_folder, false))
|
||||||
items.delete item
|
true
|
||||||
end
|
end
|
||||||
when 'project'
|
when 'project'
|
||||||
p = Project.find_by(id: item.id)
|
p = Project.find_by(id: item.id)
|
||||||
items.delete(item) unless p&.dmsf_available?
|
true unless p&.dmsf_available?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
items
|
items
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user