2018-11-17 00:37:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-14 14:57:25 +00:00
|
|
|
module Gitlab
|
2016-03-08 17:17:57 +00:00
|
|
|
module ImportExport
|
2016-06-03 10:56:29 +00:00
|
|
|
class WikiRepoSaver < RepoSaver
|
|
|
|
def save
|
2016-03-08 17:17:57 +00:00
|
|
|
@wiki = ProjectWiki.new(@project)
|
2016-05-16 08:13:00 +00:00
|
|
|
return true unless wiki_repository_exists? # it's okay to have no Wiki
|
2016-07-18 09:02:07 +00:00
|
|
|
|
2016-05-16 08:13:00 +00:00
|
|
|
bundle_to_disk(File.join(@shared.export_path, project_filename))
|
2016-03-08 17:17:57 +00:00
|
|
|
end
|
|
|
|
|
2016-05-16 08:13:00 +00:00
|
|
|
def bundle_to_disk(full_path)
|
2016-09-29 15:17:22 +00:00
|
|
|
mkdir_p(@shared.export_path)
|
2018-01-18 17:33:35 +00:00
|
|
|
@wiki.repository.bundle_to_disk(full_path)
|
2016-05-10 15:15:20 +00:00
|
|
|
rescue => e
|
2016-05-13 10:33:13 +00:00
|
|
|
@shared.error(e)
|
2016-03-08 17:17:57 +00:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-03-09 09:35:38 +00:00
|
|
|
def project_filename
|
2016-04-22 10:49:37 +00:00
|
|
|
"project.wiki.bundle"
|
2016-03-09 09:35:38 +00:00
|
|
|
end
|
|
|
|
|
2016-05-16 08:13:00 +00:00
|
|
|
def wiki_repository_exists?
|
2018-06-05 15:51:14 +00:00
|
|
|
@wiki.repository.exists? && !@wiki.repository.empty?
|
2016-03-08 17:17:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|