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
Jérome Perrin
gitlab-ce
Commits
1d63464c
Commit
1d63464c
authored
Aug 13, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix repository archive
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d8b769ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
app/controllers/projects/repositories_controller.rb
app/controllers/projects/repositories_controller.rb
+1
-5
app/services/archive_repository_service.rb
app/services/archive_repository_service.rb
+14
-0
lib/api/repositories.rb
lib/api/repositories.rb
+1
-9
No files found.
app/controllers/projects/repositories_controller.rb
View file @
1d63464c
...
...
@@ -14,11 +14,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
render_404
and
return
end
storage_path
=
Gitlab
.
config
.
gitlab
.
repository_downloads_path
@repository
.
clean_old_archives
file_path
=
@repository
.
archive_repo
(
params
[
:ref
],
storage_path
,
params
[
:format
].
downcase
)
file_path
=
ArchiveRepositoryService
.
new
.
execute
(
@project
,
params
[
:ref
],
params
[
:format
])
if
file_path
# Send file to user
...
...
app/services/archive_repository_service.rb
0 → 100644
View file @
1d63464c
class
ArchiveRepositoryService
def
execute
(
project
,
ref
,
format
)
storage_path
=
Gitlab
.
config
.
gitlab
.
repository_downloads_path
unless
File
.
directory?
(
storage_path
)
FileUtils
.
mkdir_p
(
storage_path
)
end
format
||=
'tar.gz'
repository
=
project
.
repository
repository
.
clean_old_archives
repository
.
archive_repo
(
ref
,
storage_path
,
format
.
downcase
)
end
end
lib/api/repositories.rb
View file @
1d63464c
...
...
@@ -115,21 +115,13 @@ module API
# GET /projects/:id/repository/archive
get
":id/repository/archive"
,
requirements:
{
format:
Gitlab
::
Regex
.
archive_formats_regex
}
do
authorize!
:download_code
,
user_project
repo
=
user_project
.
repository
ref
=
params
[
:sha
]
format
=
params
[
:format
]
storage_path
=
Gitlab
.
config
.
gitlab
.
repository_downloads_path
file_path
=
ArchiveRepositoryService
.
new
.
execute
(
user_project
,
params
[
:sha
],
params
[
:format
])
file_path
=
repo
.
archive_repo
(
ref
,
storage_path
,
format
)
if
file_path
&&
File
.
exists?
(
file_path
)
data
=
File
.
open
(
file_path
,
'rb'
).
read
header
[
"Content-Disposition"
]
=
"attachment; filename=
\"
#{
File
.
basename
(
file_path
)
}
\"
"
content_type
MIME
::
Types
.
type_for
(
file_path
).
first
.
content_type
env
[
'api.format'
]
=
:binary
present
data
else
not_found!
...
...
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