Move project creation to service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
e603da7360
commit
7f50c7f62c
2 changed files with 24 additions and 25 deletions
|
@ -1,30 +1,6 @@
|
|||
class ProjectObserver < BaseObserver
|
||||
def after_create(project)
|
||||
project.update_column(:last_activity_at, project.created_at)
|
||||
|
||||
return true if project.forked?
|
||||
|
||||
if project.import?
|
||||
RepositoryImportWorker.perform_in(5.seconds, project.id)
|
||||
else
|
||||
GitlabShellWorker.perform_async(
|
||||
:add_repository,
|
||||
project.path_with_namespace
|
||||
)
|
||||
|
||||
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
|
||||
end
|
||||
|
||||
if project.wiki_enabled?
|
||||
begin
|
||||
# force the creation of a wiki,
|
||||
GollumWiki.new(project, project.owner).wiki
|
||||
rescue GollumWiki::CouldNotCreateWikiError => ex
|
||||
# Prevent project observer crash
|
||||
# if failed to create wiki
|
||||
nil
|
||||
end
|
||||
end
|
||||
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
|
||||
end
|
||||
|
||||
def after_update(project)
|
||||
|
|
|
@ -58,6 +58,29 @@ module Projects
|
|||
user: current_user
|
||||
)
|
||||
end
|
||||
|
||||
@project.update_column(:last_activity_at, @project.created_at)
|
||||
|
||||
if @project.import?
|
||||
RepositoryImportWorker.perform_in(5.seconds, @project.id)
|
||||
else
|
||||
GitlabShellWorker.perform_async(
|
||||
:add_repository,
|
||||
@project.path_with_namespace
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
if @project.wiki_enabled?
|
||||
begin
|
||||
# force the creation of a wiki,
|
||||
GollumWiki.new(@project, @project.owner).wiki
|
||||
rescue GollumWiki::CouldNotCreateWikiError => ex
|
||||
# Prevent project observer crash
|
||||
# if failed to create wiki
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@project
|
||||
|
|
Loading…
Reference in a new issue