BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
10d0f438
Commit
10d0f438
authored
Apr 03, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download LFS-files from object storage for exports
Downloading the stream directly to the archive. In order to avoid conflicts with the cache.
parent
79cb4d99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
bvl-export-import-lfs.yml
changelogs/unreleased/bvl-export-import-lfs.yml
+5
-0
lfs_saver.rb
lib/gitlab/import_export/lfs_saver.rb
+10
-1
lfs_saver_spec.rb
spec/lib/gitlab/import_export/lfs_saver_spec.rb
+23
-1
No files found.
changelogs/unreleased/bvl-export-import-lfs.yml
0 → 100644
View file @
10d0f438
---
title
:
Support LFS objects when importing/exporting GitLab project archives
merge_request
:
18115
author
:
type
:
added
lib/gitlab/import_export/lfs_saver.rb
View file @
10d0f438
...
...
@@ -28,7 +28,16 @@ module Gitlab
if
lfs_object
.
local_store?
copy_file_for_lfs_object
(
lfs_object
)
else
raise
NotImplementedError
.
new
"Exporting files from object storage is not yet supported"
download_file_for_lfs_object
(
lfs_object
)
end
end
def
download_file_for_lfs_object
(
lfs_object
)
destination
=
destination_path_for_object
(
lfs_object
)
mkdir_p
(
File
.
dirname
(
destination
))
File
.
open
(
destination
,
'w'
)
do
|
file
|
IO
.
copy_stream
(
URI
.
parse
(
lfs_object
.
file
.
url
).
open
,
file
)
end
end
...
...
spec/lib/gitlab/import_export/lfs_saver_spec.rb
View file @
10d0f438
...
...
@@ -17,7 +17,7 @@ describe Gitlab::ImportExport::LfsSaver do
end
describe
'#save'
do
context
'when the project has LFS objects'
do
context
'when the project has LFS objects
locally stored
'
do
let
(
:lfs_object
)
{
create
(
:lfs_object
,
:with_file
)
}
before
do
...
...
@@ -36,5 +36,27 @@ describe Gitlab::ImportExport::LfsSaver do
expect
(
File
).
to
exist
(
"
#{
shared
.
export_path
}
/lfs-objects/
#{
lfs_object
.
oid
}
"
)
end
end
context
'when the LFS objects are stored in object storage'
do
let
(
:lfs_object
)
{
create
(
:lfs_object
,
:object_storage
)
}
before
do
allow
(
LfsObjectUploader
).
to
receive
(
:object_store_enabled?
).
and_return
(
true
)
allow
(
lfs_object
.
file
).
to
receive
(
:url
).
and_return
(
'http://my-object-storage.local'
)
project
.
lfs_objects
<<
lfs_object
end
it
'downloads the file to include in an archive'
do
fake_uri
=
double
exported_file_path
=
"
#{
shared
.
export_path
}
/lfs-objects/
#{
lfs_object
.
oid
}
"
expect
(
fake_uri
).
to
receive
(
:open
).
and_return
(
StringIO
.
new
(
'LFS file content'
))
expect
(
URI
).
to
receive
(
:parse
).
with
(
'http://my-object-storage.local'
).
and_return
(
fake_uri
)
saver
.
save
expect
(
File
.
read
(
exported_file_path
)).
to
eq
(
'LFS file content'
)
end
end
end
end
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