Commit a7f3672b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove project observer

parent 66e068bb
class ProjectObserver < BaseObserver
def after_create(project)
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end
def after_update(project)
project.send_move_instructions if project.namespace_id_changed?
project.rename_repo if project.path_changed?
end
def before_destroy(project)
project.repository.expire_cache unless project.empty_repo?
end
def after_destroy(project)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace
)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace + ".wiki"
)
project.satellite.destroy
log_info("Project \"#{project.name}\" was removed")
end
end
......@@ -51,6 +51,8 @@ module Projects
@project.creator = current_user
if @project.save
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
unless @project.group
@project.users_projects.create(
project_access: UsersProject::MASTER,
......
module Projects
class UpdateService < BaseService
def execute(role = :default)
return false unless can?(current_user, :remove_project, project)
project.repository.expire_cache unless project.empty_repo?
if project.destroy
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace
)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace + ".wiki"
)
project.satellite.destroy
log_info("Project \"#{project.name}\" was removed")
end
end
end
end
......@@ -13,7 +13,15 @@ module Projects
project.change_head(new_branch)
end
project.update_attributes(params[:project], as: role)
if project.update_attributes(params[:project], as: role)
if project.previous_changes.include?('namespace_id')
project.send_move_instructions
end
if project.previous_changes.include?('path')
project.rename_repo
end
end
end
end
end
......@@ -20,7 +20,6 @@ module Gitlab
# Activate observers that should always be running.
config.active_record.observers = :note_observer,
:project_observer,
:system_hook_observer,
:user_observer,
:users_project_observer
......
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