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
f10ca3e5
Commit
f10ca3e5
authored
Mar 30, 2021
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ExtractBase to FeatureFlagExtractBase
parent
ab5158ff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
32 deletions
+32
-32
app/uploaders/object_storage.rb
app/uploaders/object_storage.rb
+1
-1
spec/uploaders/object_storage_spec.rb
spec/uploaders/object_storage_spec.rb
+2
-2
workhorse/internal/api/api.go
workhorse/internal/api/api.go
+1
-1
workhorse/internal/filestore/save_file_opts.go
workhorse/internal/filestore/save_file_opts.go
+13
-13
workhorse/internal/filestore/save_file_opts_test.go
workhorse/internal/filestore/save_file_opts_test.go
+9
-9
workhorse/internal/upload/rewrite.go
workhorse/internal/upload/rewrite.go
+1
-1
workhorse/internal/upload/uploads_test.go
workhorse/internal/upload/uploads_test.go
+5
-5
No files found.
app/uploaders/object_storage.rb
View file @
f10ca3e5
...
...
@@ -187,7 +187,7 @@ module ObjectStorage
hash
[
:TempPath
]
=
workhorse_local_upload_path
end
hash
[
:ExtractBase
]
=
Feature
.
enabled?
(
:workhorse_extract_filename_base
)
hash
[
:
FeatureFlag
ExtractBase
]
=
Feature
.
enabled?
(
:workhorse_extract_filename_base
)
hash
[
:MaximumSize
]
=
maximum_size
if
maximum_size
.
present?
end
end
...
...
spec/uploaders/object_storage_spec.rb
View file @
f10ca3e5
...
...
@@ -443,7 +443,7 @@ RSpec.describe ObjectStorage do
shared_examples
'extracts base filename'
do
it
"returns true for ExtractsBase"
do
expect
(
subject
[
:ExtractBase
]).
to
be
true
expect
(
subject
[
:
FeatureFlag
ExtractBase
]).
to
be
true
end
context
'when workhorse_extract_filename_base is disabled'
do
...
...
@@ -452,7 +452,7 @@ RSpec.describe ObjectStorage do
end
it
"returns false for ExtractsBase"
do
expect
(
subject
[
:ExtractBase
]).
to
be
false
expect
(
subject
[
:
FeatureFlag
ExtractBase
]).
to
be
false
end
end
end
...
...
workhorse/internal/api/api.go
View file @
f10ca3e5
...
...
@@ -150,7 +150,7 @@ type Response struct {
// The maximum accepted size in bytes of the upload
MaximumSize
int64
// Feature flag used to determine whether to strip the multipart filename of any directories
ExtractBase
bool
FeatureFlag
ExtractBase
bool
}
// singleJoiningSlash is taken from reverseproxy.go:singleJoiningSlash
...
...
workhorse/internal/filestore/save_file_opts.go
View file @
f10ca3e5
...
...
@@ -63,8 +63,8 @@ type SaveFileOpts struct {
PresignedCompleteMultipart
string
// PresignedAbortMultipart is a presigned URL for AbortMultipartUpload
PresignedAbortMultipart
string
// ExtractBase uses the base of the filename and strips directories
ExtractBase
bool
//
FeatureFlag
ExtractBase uses the base of the filename and strips directories
FeatureFlag
ExtractBase
bool
}
// UseWorkhorseClientEnabled checks if the options require direct access to object storage
...
...
@@ -90,17 +90,17 @@ func GetOpts(apiResponse *api.Response) (*SaveFileOpts, error) {
}
opts
:=
SaveFileOpts
{
ExtractBase
:
apiResponse
.
ExtractBase
,
LocalTempPath
:
apiResponse
.
TempPath
,
RemoteID
:
apiResponse
.
RemoteObject
.
ID
,
RemoteURL
:
apiResponse
.
RemoteObject
.
GetURL
,
PresignedPut
:
apiResponse
.
RemoteObject
.
StoreURL
,
PresignedDelete
:
apiResponse
.
RemoteObject
.
DeleteURL
,
PutHeaders
:
apiResponse
.
RemoteObject
.
PutHeaders
,
UseWorkhorseClient
:
apiResponse
.
RemoteObject
.
UseWorkhorseClient
,
RemoteTempObjectID
:
apiResponse
.
RemoteObject
.
RemoteTempObjectID
,
Deadline
:
time
.
Now
()
.
Add
(
timeout
),
MaximumSize
:
apiResponse
.
MaximumSize
,
FeatureFlagExtractBase
:
apiResponse
.
FeatureFlag
ExtractBase
,
LocalTempPath
:
apiResponse
.
TempPath
,
RemoteID
:
apiResponse
.
RemoteObject
.
ID
,
RemoteURL
:
apiResponse
.
RemoteObject
.
GetURL
,
PresignedPut
:
apiResponse
.
RemoteObject
.
StoreURL
,
PresignedDelete
:
apiResponse
.
RemoteObject
.
DeleteURL
,
PutHeaders
:
apiResponse
.
RemoteObject
.
PutHeaders
,
UseWorkhorseClient
:
apiResponse
.
RemoteObject
.
UseWorkhorseClient
,
RemoteTempObjectID
:
apiResponse
.
RemoteObject
.
RemoteTempObjectID
,
Deadline
:
time
.
Now
()
.
Add
(
timeout
),
MaximumSize
:
apiResponse
.
MaximumSize
,
}
if
opts
.
LocalTempPath
!=
""
&&
opts
.
RemoteID
!=
""
{
...
...
workhorse/internal/filestore/save_file_opts_test.go
View file @
f10ca3e5
...
...
@@ -57,18 +57,18 @@ func TestSaveFileOptsLocalAndRemote(t *testing.T) {
func
TestGetOpts
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
multipart
*
api
.
MultipartUploadParams
customPutHeaders
bool
putHeaders
map
[
string
]
string
extractBase
bool
name
string
multipart
*
api
.
MultipartUploadParams
customPutHeaders
bool
putHeaders
map
[
string
]
string
FeatureFlagExtractBase
bool
}{
{
name
:
"Single upload"
,
},
{
name
:
"Single upload w/ e
xtractBase enabled"
,
e
xtractBase
:
true
,
name
:
"Single upload w/ FeatureFlagE
xtractBase enabled"
,
FeatureFlagE
xtractBase
:
true
,
},
{
name
:
"Multipart upload"
,
multipart
:
&
api
.
MultipartUploadParams
{
...
...
@@ -98,7 +98,7 @@ func TestGetOpts(t *testing.T) {
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
apiResponse
:=
&
api
.
Response
{
ExtractBase
:
test
.
e
xtractBase
,
FeatureFlagExtractBase
:
test
.
FeatureFlagE
xtractBase
,
RemoteObject
:
api
.
RemoteObject
{
Timeout
:
10
,
ID
:
"id"
,
...
...
@@ -114,7 +114,7 @@ func TestGetOpts(t *testing.T) {
opts
,
err
:=
filestore
.
GetOpts
(
apiResponse
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
apiResponse
.
ExtractBase
,
opts
.
ExtractBase
)
require
.
Equal
(
t
,
apiResponse
.
FeatureFlagExtractBase
,
opts
.
FeatureFlag
ExtractBase
)
require
.
Equal
(
t
,
apiResponse
.
TempPath
,
opts
.
LocalTempPath
)
require
.
WithinDuration
(
t
,
deadline
,
opts
.
Deadline
,
time
.
Second
)
require
.
Equal
(
t
,
apiResponse
.
RemoteObject
.
ID
,
opts
.
RemoteID
)
...
...
workhorse/internal/upload/rewrite.go
View file @
f10ca3e5
...
...
@@ -115,7 +115,7 @@ func (rew *rewriter) handleFilePart(ctx context.Context, name string, p *multipa
filename
:=
p
.
FileName
()
if
opts
.
ExtractBase
{
if
opts
.
FeatureFlag
ExtractBase
{
filename
=
filepath
.
Base
(
filename
)
}
...
...
workhorse/internal/upload/uploads_test.go
View file @
f10ca3e5
...
...
@@ -325,10 +325,10 @@ func TestInvalidFileNames(t *testing.T) {
defer
os
.
RemoveAll
(
tempPath
)
for
_
,
testCase
:=
range
[]
struct
{
filename
string
code
int
extractBase
bool
expectedPrefix
string
filename
string
code
int
FeatureFlagExtractBase
bool
expectedPrefix
string
}{
{
"foobar"
,
200
,
false
,
"foobar"
},
// sanity check for test setup below
{
"foo/bar"
,
500
,
false
,
""
},
...
...
@@ -356,7 +356,7 @@ func TestInvalidFileNames(t *testing.T) {
apiResponse
:=
&
api
.
Response
{
TempPath
:
tempPath
}
preparer
:=
&
DefaultPreparer
{}
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
opts
.
ExtractBase
=
testCase
.
e
xtractBase
opts
.
FeatureFlagExtractBase
=
testCase
.
FeatureFlagE
xtractBase
require
.
NoError
(
t
,
err
)
HandleFileUploads
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
SavedFileTracker
{
Request
:
httpRequest
},
opts
)
...
...
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