Skip to content

Commit c97d8ed

Browse files
committed
fix
1 parent c5edcd8 commit c97d8ed

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

routers/api/packages/swift/swift.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,19 @@ func DownloadManifest(ctx *context.Context) {
292292

293293
// formFileOptionalReadCloser returns (nil, nil) if the formKey is not present.
294294
func formFileOptionalReadCloser(ctx *context.Context, formKey string) (io.ReadCloser, error) {
295-
var file io.ReadCloser
296-
multipartFile, _, err := ctx.Req.FormFile(formKey) // it calls ParseMultipartForm automatically
295+
multipartFile, _, err := ctx.Req.FormFile(formKey)
297296
if err != nil && !errors.Is(err, http.ErrMissingFile) {
298297
return nil, err
299298
}
300299
if multipartFile != nil {
301300
return multipartFile, nil
302301
}
303302

304-
_ = ctx.Req.ParseForm() // although ParseForm should have been called by FormFile->ParseMultipartForm, it's safe to call it again
305-
if !ctx.Req.Form.Has(formKey) {
303+
content := ctx.Req.FormValue(formKey)
304+
if content == "" {
306305
return nil, nil
307306
}
308-
file = io.NopCloser(strings.NewReader(ctx.Req.FormValue(formKey)))
309-
return file, nil
307+
return io.NopCloser(strings.NewReader(ctx.Req.FormValue(formKey))), nil
310308
}
311309

312310
// UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6

0 commit comments

Comments
 (0)