Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c75187df
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c75187df
编写于
12月 02, 2017
作者:
T
Travis Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add project export API implementation
上级
a4308c53
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
54 addition
and
10 deletion
+54
-10
app/models/project.rb
app/models/project.rb
+2
-3
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+1
-1
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/project_export.rb
lib/api/project_export.rb
+36
-0
lib/gitlab/import_export/importer.rb
lib/gitlab/import_export/importer.rb
+1
-1
lib/gitlab/import_export/shared.rb
lib/gitlab/import_export/shared.rb
+13
-5
未找到文件。
app/models/project.rb
浏览文件 @
c75187df
...
...
@@ -1560,7 +1560,7 @@ class Project < ActiveRecord::Base
def
export_path
return
nil
unless
namespace
.
present?
||
hashed_storage?
(
:repository
)
File
.
join
(
Gitlab
::
ImportExport
.
storage_path
,
disk_path
)
Gitlab
::
ImportExport
::
Shared
.
new
(
self
).
archive_path
end
def
export_project_path
...
...
@@ -1578,8 +1578,7 @@ class Project < ActiveRecord::Base
end
def
export_in_progress?
shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
relative_path:
File
.
join
(
disk_path
,
'work'
))
File
.
directory?
(
shared
.
export_path
)
Gitlab
::
ImportExport
::
Shared
.
new
(
self
).
active_export_count
>
0
end
def
remove_exports
...
...
app/services/projects/import_export/export_service.rb
浏览文件 @
c75187df
...
...
@@ -2,7 +2,7 @@ module Projects
module
ImportExport
class
ExportService
<
BaseService
def
execute
(
_options
=
{})
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
relative_path:
File
.
join
(
project
.
disk_path
,
'work'
)
)
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
save_all
end
...
...
lib/api/api.rb
浏览文件 @
c75187df
...
...
@@ -138,6 +138,7 @@ module API
mount
::
API
::
PagesDomains
mount
::
API
::
Pipelines
mount
::
API
::
PipelineSchedules
mount
::
API
::
ProjectExport
mount
::
API
::
ProjectImport
mount
::
API
::
ProjectHooks
mount
::
API
::
Projects
...
...
lib/api/project_export.rb
0 → 100644
浏览文件 @
c75187df
module
API
class
ProjectExport
<
Grape
::
API
before
do
not_found!
unless
Gitlab
::
CurrentSettings
.
current_application_settings
.
project_export_enabled?
authorize_admin_project
end
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get export status'
do
success
Entities
::
ProjectExportStatus
end
get
':id/export'
do
present
user_project
,
with:
Entities
::
ProjectExportStatus
end
desc
'Download export'
get
':id/export/download'
do
path
=
user_project
.
export_project_path
render_api_error!
(
'404 Not found or has expired'
,
404
)
unless
path
present_file!
(
path
,
File
.
basename
(
path
),
'application/gzip'
)
end
desc
'Start export'
post
':id/export'
do
user_project
.
add_export_job
(
current_user:
current_user
)
accepted!
end
end
end
end
lib/gitlab/import_export/importer.rb
浏览文件 @
c75187df
...
...
@@ -9,7 +9,7 @@ module Gitlab
@archive_file
=
project
.
import_source
@current_user
=
project
.
creator
@project
=
project
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
relative_path:
path_with_namespace
)
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
end
def
execute
...
...
lib/gitlab/import_export/shared.rb
浏览文件 @
c75187df
module
Gitlab
module
ImportExport
class
Shared
attr_reader
:errors
,
:
opts
attr_reader
:errors
,
:
project
def
initialize
(
opts
)
@
opts
=
opts
def
initialize
(
project
)
@
project
=
project
@errors
=
[]
end
def
active_export_count
Dir
[
File
.
join
(
archive_path
,
'*'
)].
count
{
|
name
|
File
.
directory?
(
name
)
}
end
def
export_path
@export_path
||=
Gitlab
::
ImportExport
.
export_path
(
relative_path:
relative_path
)
end
...
...
@@ -31,11 +35,15 @@ module Gitlab
private
def
relative_path
File
.
join
(
opts
[
:relative_path
]
,
SecureRandom
.
hex
)
File
.
join
(
relative_archive_path
,
SecureRandom
.
hex
)
end
def
relative_archive_path
File
.
join
(
opts
[
:relative_path
],
'..'
)
if
@project
.
is_a?
(
Project
)
@project
.
disk_path
else
@project
[
:relative_path
]
end
end
def
error_out
(
message
,
caller
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录