Skip to content

Commit 10bfd7d

Browse files
committed
More performance improvements.
This patch should remove all remaining need for recursive calls to update_repositories. Will log such calls as errors in upcoming major code fix...
1 parent 33aafdd commit 10bfd7d

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

app/controllers/gitolite_public_keys_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ def edit
1010
end
1111

1212
def delete
13+
GitHostingObserver.set_update_active(false)
1314
@gitolite_public_key[:active] = 0
1415
@gitolite_public_key.save
1516
redirect_to url_for(:controller => 'my', :action => 'account')
17+
GitHostingObserver.set_update_active(true)
1618
end
1719

1820
def update
@@ -25,13 +27,15 @@ def update
2527
end
2628

2729
def create
30+
GitHostingObserver.set_update_active(false)
2831
@gitolite_public_key = GitolitePublicKey.new(params[:public_key].merge(:user => @user))
2932
if @gitolite_public_key.save
3033
flash[:notice] = l(:notice_public_key_added)
3134
else
3235
@gitolite_public_key = GitolitePublicKey.new(:user => @user)
3336
end
3437
redirect_to url_for(:controller => 'my', :action => 'account')
38+
GitHostingObserver.set_update_active(true)
3539
end
3640

3741
protected

init.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
require 'git_hosting/patches/members_controller_patch'
7575
MembersController.send(:include, GitHosting::Patches::MembersControllerPatch)
7676

77+
require_dependency 'users_controller'
78+
require 'git_hosting/patches/users_controller_patch'
79+
UsersController.send(:include, GitHosting::Patches::UsersControllerPatch)
80+
81+
require_dependency 'roles_controller'
82+
require 'git_hosting/patches/roles_controller_patch'
83+
RolesController.send(:include, GitHosting::Patches::RolesControllerPatch)
84+
7785
require_dependency 'git_hosting/patches/repository_cia_filters'
7886
end
7987

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module GitHosting
2+
module Patches
3+
module RolesControllerPatch
4+
def edit_with_disable_update
5+
# Turn of updates during repository update
6+
GitHostingObserver.set_update_active(false);
7+
8+
# Do actual update
9+
edit_without_disable_update
10+
11+
# Reenable updates to perform a single update
12+
GitHostingObserver.set_update_active(true);
13+
end
14+
def destroy_with_disable_update
15+
# Turn of updates during repository update
16+
GitHostingObserver.set_update_active(false);
17+
18+
# Do actual update
19+
destroy_without_disable_update
20+
21+
# Reenable updates to perform a single update
22+
GitHostingObserver.set_update_active(true);
23+
end
24+
def self.included(base)
25+
base.class_eval do
26+
unloadable
27+
end
28+
begin
29+
base.send(:alias_method_chain, :edit, :disable_update)
30+
base.send(:alias_method_chain, :destroy, :disable_update)
31+
rescue
32+
end
33+
end
34+
end
35+
end
36+
end
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module GitHosting
2+
module Patches
3+
module UsersControllerPatch
4+
def create_with_disable_update
5+
# Turn of updates during repository update
6+
GitHostingObserver.set_update_active(false);
7+
8+
# Do actual update
9+
create_without_disable_update
10+
11+
# Reenable updates to perform a single update
12+
GitHostingObserver.set_update_active(true);
13+
end
14+
def update_with_disable_update
15+
# Turn of updates during repository update
16+
GitHostingObserver.set_update_active(false);
17+
18+
# Do actual update
19+
update_without_disable_update
20+
21+
# Reenable updates to perform a single update
22+
GitHostingObserver.set_update_active(true);
23+
end
24+
def destroy_with_disable_update
25+
# Turn of updates during repository update
26+
GitHostingObserver.set_update_active(false);
27+
28+
# Do actual update
29+
destroy_without_disable_update
30+
31+
# Reenable updates to perform a single update
32+
GitHostingObserver.set_update_active(true);
33+
end
34+
def edit_membership_with_disable_update
35+
# Turn of updates during repository update
36+
GitHostingObserver.set_update_active(false);
37+
38+
# Do actual update
39+
edit_membership_without_disable_update
40+
41+
# Reenable updates to perform a single update
42+
GitHostingObserver.set_update_active(true);
43+
end
44+
45+
def self.included(base)
46+
base.class_eval do
47+
unloadable
48+
end
49+
begin
50+
base.send(:alias_method_chain, :create, :disable_update)
51+
base.send(:alias_method_chain, :update, :disable_update)
52+
base.send(:alias_method_chain, :destroy, :disable_update)
53+
base.send(:alias_method_chain, :edit_membershipt, :disable_update)
54+
rescue
55+
end
56+
end
57+
end
58+
end
59+
end

0 commit comments

Comments
 (0)