Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
27442862
Commit
27442862
authored
Sep 07, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code based on feedback
parent
a2aa5058
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
22 additions
and
18 deletions
+22
-18
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-2
app/models/project.rb
app/models/project.rb
+8
-4
lib/api/project_export.rb
lib/api/project_export.rb
+2
-2
lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
...ort/after_export_strategies/base_after_export_strategy.rb
+1
-1
lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
...ort_export/after_export_strategies/web_upload_strategy.rb
+2
-2
lib/gitlab/import_export/saver.rb
lib/gitlab/import_export/saver.rb
+2
-2
lib/tasks/gitlab/update_templates.rake
lib/tasks/gitlab/update_templates.rake
+1
-1
spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
...fter_export_strategies/base_after_export_strategy_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/requests/api/project_export_spec.rb
spec/requests/api/project_export_spec.rb
+1
-1
spec/support/import_export/export_file_helper.rb
spec/support/import_export/export_file_helper.rb
+1
-1
No files found.
app/controllers/projects_controller.rb
View file @
27442862
...
@@ -191,8 +191,8 @@ class ProjectsController < Projects::ApplicationController
...
@@ -191,8 +191,8 @@ class ProjectsController < Projects::ApplicationController
end
end
def
download_export
def
download_export
if
@project
.
export_project_
object_
exists?
if
@project
.
export_project_exists?
send_upload
(
@project
.
import_export_upload
.
export_file
)
send_upload
(
@project
.
export_file
)
else
else
redirect_to
(
redirect_to
(
edit_project_path
(
@project
,
anchor:
'js-export-project'
),
edit_project_path
(
@project
,
anchor:
'js-export-project'
),
...
...
app/models/project.rb
View file @
27442862
...
@@ -1738,7 +1738,7 @@ class Project < ActiveRecord::Base
...
@@ -1738,7 +1738,7 @@ class Project < ActiveRecord::Base
:started
:started
elsif
after_export_in_progress?
elsif
after_export_in_progress?
:after_export_action
:after_export_action
elsif
export_project_
object_
exists?
elsif
export_project_exists?
:finished
:finished
else
else
:none
:none
...
@@ -1754,14 +1754,18 @@ class Project < ActiveRecord::Base
...
@@ -1754,14 +1754,18 @@ class Project < ActiveRecord::Base
end
end
def
remove_exports
def
remove_exports
return
unless
export_project_
object_
exists?
return
unless
export_project_exists?
import_export_upload
.
remove_export_file!
import_export_upload
.
remove_export_file!
import_export_upload
.
save
import_export_upload
.
save
end
end
def
export_project_object_exists?
def
export_project_exists?
import_export_upload
&
.
export_file
&
.
file
export_file
&
.
file
end
def
export_file
import_export_upload
&
.
export_file
end
end
def
full_path_slug
def
full_path_slug
...
...
lib/api/project_export.rb
View file @
27442862
...
@@ -21,8 +21,8 @@ module API
...
@@ -21,8 +21,8 @@ module API
detail
'This feature was introduced in GitLab 10.6.'
detail
'This feature was introduced in GitLab 10.6.'
end
end
get
':id/export/download'
do
get
':id/export/download'
do
if
user_project
.
export_project_
object_
exists?
if
user_project
.
export_project_exists?
present_carrierwave_file!
(
user_
project
.
import_export_upload
.
export_file
)
present_carrierwave_file!
(
user_
project
.
export_file
)
else
else
render_api_error!
(
'404 Not found or has expired'
,
404
)
render_api_error!
(
'404 Not found or has expired'
,
404
)
end
end
...
...
lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
View file @
27442862
...
@@ -84,7 +84,7 @@ module Gitlab
...
@@ -84,7 +84,7 @@ module Gitlab
end
end
def
object_storage?
def
object_storage?
project
.
export_project_
object_
exists?
project
.
export_project_exists?
end
end
end
end
end
end
...
...
lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
View file @
27442862
...
@@ -44,7 +44,7 @@ module Gitlab
...
@@ -44,7 +44,7 @@ module Gitlab
end
end
def
export_file
def
export_file
project
.
import_export_upload
.
export_file
.
open
project
.
export_file
.
open
end
end
def
send_file_options
def
send_file_options
...
@@ -59,7 +59,7 @@ module Gitlab
...
@@ -59,7 +59,7 @@ module Gitlab
end
end
def
export_size
def
export_size
project
.
import_export_upload
.
export_file
.
file
.
size
project
.
export_file
.
file
.
size
end
end
end
end
end
end
...
...
lib/gitlab/import_export/saver.rb
View file @
27442862
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
Rails
.
logger
.
info
(
"Saved project export
#{
archive_file
}
"
)
Rails
.
logger
.
info
(
"Saved project export
#{
archive_file
}
"
)
save_
on_object_storage
save_
upload
else
else
@shared
.
error
(
Gitlab
::
ImportExport
::
Error
.
new
(
error_message
))
@shared
.
error
(
Gitlab
::
ImportExport
::
Error
.
new
(
error_message
))
false
false
...
@@ -49,7 +49,7 @@ module Gitlab
...
@@ -49,7 +49,7 @@ module Gitlab
@archive_file
||=
File
.
join
(
@shared
.
archive_path
,
Gitlab
::
ImportExport
.
export_filename
(
project:
@project
))
@archive_file
||=
File
.
join
(
@shared
.
archive_path
,
Gitlab
::
ImportExport
.
export_filename
(
project:
@project
))
end
end
def
save_
on_object_storage
def
save_
upload
upload
=
ImportExportUpload
.
find_or_initialize_by
(
project:
@project
)
upload
=
ImportExportUpload
.
find_or_initialize_by
(
project:
@project
)
File
.
open
(
archive_file
)
{
|
file
|
upload
.
export_file
=
file
}
File
.
open
(
archive_file
)
{
|
file
|
upload
.
export_file
=
file
}
...
...
lib/tasks/gitlab/update_templates.rake
View file @
27442862
...
@@ -54,7 +54,7 @@ namespace :gitlab do
...
@@ -54,7 +54,7 @@ namespace :gitlab do
end
end
Projects
::
ImportExport
::
ExportService
.
new
(
project
,
admin
).
execute
Projects
::
ImportExport
::
ExportService
.
new
(
project
,
admin
).
execute
download_or_copy_upload
(
project
.
import_export_upload
.
export_file
,
template
.
archive_path
)
download_or_copy_upload
(
project
.
export_file
,
template
.
archive_path
)
Projects
::
DestroyService
.
new
(
admin
,
project
).
execute
Projects
::
DestroyService
.
new
(
admin
,
project
).
execute
puts
"Exported
#{
template
.
name
}
"
.
green
puts
"Exported
#{
template
.
name
}
"
.
green
end
end
...
...
spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
View file @
27442862
...
@@ -12,7 +12,7 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
...
@@ -12,7 +12,7 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
end
end
it
'returns if project exported file is not found'
do
it
'returns if project exported file is not found'
do
allow
(
project
).
to
receive
(
:export_project_
object_
exists?
).
and_return
(
false
)
allow
(
project
).
to
receive
(
:export_project_exists?
).
and_return
(
false
)
expect
(
service
).
not_to
receive
(
:strategy_execute
)
expect
(
service
).
not_to
receive
(
:strategy_execute
)
...
...
spec/models/project_spec.rb
View file @
27442862
...
@@ -2859,7 +2859,7 @@ describe Project do
...
@@ -2859,7 +2859,7 @@ describe Project do
it
'removes the export'
do
it
'removes the export'
do
project
.
remove_exports
project
.
remove_exports
expect
(
project
.
export_project_
object_
exists?
).
to
be_falsey
expect
(
project
.
export_project_exists?
).
to
be_falsey
end
end
end
end
...
...
spec/requests/api/project_export_spec.rb
View file @
27442862
...
@@ -189,7 +189,7 @@ describe API::ProjectExport do
...
@@ -189,7 +189,7 @@ describe API::ProjectExport do
end
end
it
'has removed the export'
do
it
'has removed the export'
do
expect
(
project_after_export
.
export_project_
object_
exists?
).
to
be_falsey
expect
(
project_after_export
.
export_project_exists?
).
to
be_falsey
end
end
it_behaves_like
'404 response'
do
it_behaves_like
'404 response'
do
...
...
spec/support/import_export/export_file_helper.rb
View file @
27442862
...
@@ -52,7 +52,7 @@ module ExportFileHelper
...
@@ -52,7 +52,7 @@ module ExportFileHelper
# Expands the compressed file for an exported project into +tmpdir+
# Expands the compressed file for an exported project into +tmpdir+
def
in_directory_with_expanded_export
(
project
)
def
in_directory_with_expanded_export
(
project
)
Dir
.
mktmpdir
do
|
tmpdir
|
Dir
.
mktmpdir
do
|
tmpdir
|
export_file
=
project
.
import_export_upload
.
export_file
.
path
export_file
=
project
.
export_file
.
path
_output
,
exit_status
=
Gitlab
::
Popen
.
popen
(
%W{tar -zxf
#{
export_file
}
-C
#{
tmpdir
}
}
)
_output
,
exit_status
=
Gitlab
::
Popen
.
popen
(
%W{tar -zxf
#{
export_file
}
-C
#{
tmpdir
}
}
)
yield
(
exit_status
,
tmpdir
)
yield
(
exit_status
,
tmpdir
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment