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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e20e0627
Commit
e20e0627
authored
May 06, 2019
by
Patrick Bajao
Committed by
Nick Thomas
May 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix uploading of LFS tracked file through UI
parent
38d57a61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
app/services/lfs/file_transformer.rb
app/services/lfs/file_transformer.rb
+8
-1
changelogs/unreleased/61203-fix-lfs-ui-upload.yml
changelogs/unreleased/61203-fix-lfs-ui-upload.yml
+5
-0
spec/services/lfs/file_transformer_spec.rb
spec/services/lfs/file_transformer_spec.rb
+19
-0
No files found.
app/services/lfs/file_transformer.rb
View file @
e20e0627
...
...
@@ -24,7 +24,7 @@ module Lfs
def
new_file
(
file_path
,
file_content
,
encoding:
nil
)
if
project
.
lfs_enabled?
&&
lfs_file?
(
file_path
)
file_content
=
Base64
.
decode64
(
file_content
)
if
encoding
==
'base64'
file_content
=
parse_file_content
(
file_content
,
encoding:
encoding
)
lfs_pointer_file
=
Gitlab
::
Git
::
LfsPointerFile
.
new
(
file_content
)
lfs_object
=
create_lfs_object!
(
lfs_pointer_file
,
file_content
)
...
...
@@ -66,5 +66,12 @@ module Lfs
def
link_lfs_object!
(
lfs_object
)
project
.
lfs_objects
<<
lfs_object
end
def
parse_file_content
(
file_content
,
encoding:
nil
)
return
file_content
.
read
if
file_content
.
respond_to?
(
:read
)
return
Base64
.
decode64
(
file_content
)
if
encoding
==
'base64'
file_content
end
end
end
changelogs/unreleased/61203-fix-lfs-ui-upload.yml
0 → 100644
View file @
e20e0627
---
title
:
Fix uploading of LFS tracked file through UI
merge_request
:
28052
author
:
type
:
fixed
spec/services/lfs/file_transformer_spec.rb
View file @
e20e0627
...
...
@@ -64,6 +64,25 @@ describe Lfs::FileTransformer do
expect
(
result
.
encoding
).
to
eq
(
'text'
)
end
context
'when an actual file is passed'
do
let
(
:file
)
{
Tempfile
.
new
(
file_path
)
}
before
do
file
.
write
(
file_content
)
file
.
rewind
end
after
do
file
.
unlink
end
it
"creates an LfsObject with the file's content"
do
subject
.
new_file
(
file_path
,
file
)
expect
(
LfsObject
.
last
.
file
.
read
).
to
eq
file_content
end
end
context
"when doesn't use LFS"
do
let
(
:file_path
)
{
'other.filetype'
}
...
...
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