summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c5aed71ad04..87ef80c9b14 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -346,7 +346,13 @@ class ApplicationController < ActionController::Base
def close_project_repository
return unless @project
- project = @project
- ObjectSpace.define_finalizer(self, lambda { project.reload_repository! })
+ project = WeakRef.new(@project)
+ ObjectSpace.define_finalizer(self,
+ lambda do
+ begin
+ project.reload_repository! if project.weakref_alive?
+ rescue WeakRef::RefError
+ end
+ end)
end
end