Commit f10ca3e5 authored by Stan Hu's avatar Stan Hu

Rename ExtractBase to FeatureFlagExtractBase

parent ab5158ff
...@@ -187,7 +187,7 @@ module ObjectStorage ...@@ -187,7 +187,7 @@ module ObjectStorage
hash[:TempPath] = workhorse_local_upload_path hash[:TempPath] = workhorse_local_upload_path
end end
hash[:ExtractBase] = Feature.enabled?(:workhorse_extract_filename_base) hash[:FeatureFlagExtractBase] = Feature.enabled?(:workhorse_extract_filename_base)
hash[:MaximumSize] = maximum_size if maximum_size.present? hash[:MaximumSize] = maximum_size if maximum_size.present?
end end
end end
......
...@@ -443,7 +443,7 @@ RSpec.describe ObjectStorage do ...@@ -443,7 +443,7 @@ RSpec.describe ObjectStorage do
shared_examples 'extracts base filename' do shared_examples 'extracts base filename' do
it "returns true for ExtractsBase" do it "returns true for ExtractsBase" do
expect(subject[:ExtractBase]).to be true expect(subject[:FeatureFlagExtractBase]).to be true
end end
context 'when workhorse_extract_filename_base is disabled' do context 'when workhorse_extract_filename_base is disabled' do
...@@ -452,7 +452,7 @@ RSpec.describe ObjectStorage do ...@@ -452,7 +452,7 @@ RSpec.describe ObjectStorage do
end end
it "returns false for ExtractsBase" do it "returns false for ExtractsBase" do
expect(subject[:ExtractBase]).to be false expect(subject[:FeatureFlagExtractBase]).to be false
end end
end end
end end
......
...@@ -150,7 +150,7 @@ type Response struct { ...@@ -150,7 +150,7 @@ type Response struct {
// The maximum accepted size in bytes of the upload // The maximum accepted size in bytes of the upload
MaximumSize int64 MaximumSize int64
// Feature flag used to determine whether to strip the multipart filename of any directories // Feature flag used to determine whether to strip the multipart filename of any directories
ExtractBase bool FeatureFlagExtractBase bool
} }
// singleJoiningSlash is taken from reverseproxy.go:singleJoiningSlash // singleJoiningSlash is taken from reverseproxy.go:singleJoiningSlash
......
...@@ -63,8 +63,8 @@ type SaveFileOpts struct { ...@@ -63,8 +63,8 @@ type SaveFileOpts struct {
PresignedCompleteMultipart string PresignedCompleteMultipart string
// PresignedAbortMultipart is a presigned URL for AbortMultipartUpload // PresignedAbortMultipart is a presigned URL for AbortMultipartUpload
PresignedAbortMultipart string PresignedAbortMultipart string
// ExtractBase uses the base of the filename and strips directories // FeatureFlagExtractBase uses the base of the filename and strips directories
ExtractBase bool FeatureFlagExtractBase bool
} }
// UseWorkhorseClientEnabled checks if the options require direct access to object storage // UseWorkhorseClientEnabled checks if the options require direct access to object storage
...@@ -90,7 +90,7 @@ func GetOpts(apiResponse *api.Response) (*SaveFileOpts, error) { ...@@ -90,7 +90,7 @@ func GetOpts(apiResponse *api.Response) (*SaveFileOpts, error) {
} }
opts := SaveFileOpts{ opts := SaveFileOpts{
ExtractBase: apiResponse.ExtractBase, FeatureFlagExtractBase: apiResponse.FeatureFlagExtractBase,
LocalTempPath: apiResponse.TempPath, LocalTempPath: apiResponse.TempPath,
RemoteID: apiResponse.RemoteObject.ID, RemoteID: apiResponse.RemoteObject.ID,
RemoteURL: apiResponse.RemoteObject.GetURL, RemoteURL: apiResponse.RemoteObject.GetURL,
......
...@@ -61,14 +61,14 @@ func TestGetOpts(t *testing.T) { ...@@ -61,14 +61,14 @@ func TestGetOpts(t *testing.T) {
multipart *api.MultipartUploadParams multipart *api.MultipartUploadParams
customPutHeaders bool customPutHeaders bool
putHeaders map[string]string putHeaders map[string]string
extractBase bool FeatureFlagExtractBase bool
}{ }{
{ {
name: "Single upload", name: "Single upload",
}, },
{ {
name: "Single upload w/ extractBase enabled", name: "Single upload w/ FeatureFlagExtractBase enabled",
extractBase: true, FeatureFlagExtractBase: true,
}, { }, {
name: "Multipart upload", name: "Multipart upload",
multipart: &api.MultipartUploadParams{ multipart: &api.MultipartUploadParams{
...@@ -98,7 +98,7 @@ func TestGetOpts(t *testing.T) { ...@@ -98,7 +98,7 @@ func TestGetOpts(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
apiResponse := &api.Response{ apiResponse := &api.Response{
ExtractBase: test.extractBase, FeatureFlagExtractBase: test.FeatureFlagExtractBase,
RemoteObject: api.RemoteObject{ RemoteObject: api.RemoteObject{
Timeout: 10, Timeout: 10,
ID: "id", ID: "id",
...@@ -114,7 +114,7 @@ func TestGetOpts(t *testing.T) { ...@@ -114,7 +114,7 @@ func TestGetOpts(t *testing.T) {
opts, err := filestore.GetOpts(apiResponse) opts, err := filestore.GetOpts(apiResponse)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, apiResponse.ExtractBase, opts.ExtractBase) require.Equal(t, apiResponse.FeatureFlagExtractBase, opts.FeatureFlagExtractBase)
require.Equal(t, apiResponse.TempPath, opts.LocalTempPath) require.Equal(t, apiResponse.TempPath, opts.LocalTempPath)
require.WithinDuration(t, deadline, opts.Deadline, time.Second) require.WithinDuration(t, deadline, opts.Deadline, time.Second)
require.Equal(t, apiResponse.RemoteObject.ID, opts.RemoteID) require.Equal(t, apiResponse.RemoteObject.ID, opts.RemoteID)
......
...@@ -115,7 +115,7 @@ func (rew *rewriter) handleFilePart(ctx context.Context, name string, p *multipa ...@@ -115,7 +115,7 @@ func (rew *rewriter) handleFilePart(ctx context.Context, name string, p *multipa
filename := p.FileName() filename := p.FileName()
if opts.ExtractBase { if opts.FeatureFlagExtractBase {
filename = filepath.Base(filename) filename = filepath.Base(filename)
} }
......
...@@ -327,7 +327,7 @@ func TestInvalidFileNames(t *testing.T) { ...@@ -327,7 +327,7 @@ func TestInvalidFileNames(t *testing.T) {
for _, testCase := range []struct { for _, testCase := range []struct {
filename string filename string
code int code int
extractBase bool FeatureFlagExtractBase bool
expectedPrefix string expectedPrefix string
}{ }{
{"foobar", 200, false, "foobar"}, // sanity check for test setup below {"foobar", 200, false, "foobar"}, // sanity check for test setup below
...@@ -356,7 +356,7 @@ func TestInvalidFileNames(t *testing.T) { ...@@ -356,7 +356,7 @@ func TestInvalidFileNames(t *testing.T) {
apiResponse := &api.Response{TempPath: tempPath} apiResponse := &api.Response{TempPath: tempPath}
preparer := &DefaultPreparer{} preparer := &DefaultPreparer{}
opts, _, err := preparer.Prepare(apiResponse) opts, _, err := preparer.Prepare(apiResponse)
opts.ExtractBase = testCase.extractBase opts.FeatureFlagExtractBase = testCase.FeatureFlagExtractBase
require.NoError(t, err) require.NoError(t, err)
HandleFileUploads(response, httpRequest, nilHandler, apiResponse, &SavedFileTracker{Request: httpRequest}, opts) HandleFileUploads(response, httpRequest, nilHandler, apiResponse, &SavedFileTracker{Request: httpRequest}, opts)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment