Commit 99eefcb5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Invalidate events cache when project was moved

parent d3a0fa76d8e8
......@@ -423,6 +423,7 @@ def rename_repo
gitlab_shell.rm_satellites(old_path_with_namespace)
ensure_satellite_exists
send_move_instructions
reset_events_cache
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
......@@ -434,4 +435,19 @@ def rename_repo
raise Exception.new('repository cannot be renamed')
end
end
# Reset events cache related to this project
#
# Since we do cache @event we need to reset cache in special cases:
# * when project was moved
# * when project was renamed
# Events cache stored like events/23-20130109142513.
# The cache key includes updated_at timestamp.
# Thus it will automatically generate a new fragment
# when the event is updated because the key changes.
def reset_events_cache
Event.where(project_id: self.id).
order('id DESC').limit(100).
update_all(updated_at: Time.now)
end
end
......@@ -32,6 +32,9 @@ def transfer(project, new_namespace)
# create satellite repo
project.ensure_satellite_exists
# clear project cached events
project.reset_events_cache
true
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment