Skip to content

Commit 47f9967

Browse files
authored
Merge branch 'main' into main
2 parents 2366dd7 + 1c28c47 commit 47f9967

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

routers/api/packages/container/container.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ func PostBlobsUploads(ctx *context.Context) {
320320

321321
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
322322
func GetBlobsUpload(ctx *context.Context) {
323+
image := ctx.PathParam("image")
323324
uuid := ctx.PathParam("uuid")
324325

325326
upload, err := packages_model.GetBlobUploadByID(ctx, uuid)
@@ -334,6 +335,7 @@ func GetBlobsUpload(ctx *context.Context) {
334335

335336
// FIXME: undefined behavior when the uploaded content is empty: https://github.com/opencontainers/distribution-spec/issues/578
336337
respHeaders := &containerHeaders{
338+
Location: fmt.Sprintf("/v2/%s/%s/blobs/uploads/%s", ctx.Package.Owner.LowerName, image, upload.ID),
337339
UploadUUID: upload.ID,
338340
Status: http.StatusNoContent,
339341
}
@@ -386,7 +388,7 @@ func PatchBlobsUpload(ctx *context.Context) {
386388
UploadUUID: uploader.ID,
387389
Status: http.StatusAccepted,
388390
}
389-
if contentRange != "" {
391+
if uploader.Size() > 0 {
390392
respHeaders.Range = fmt.Sprintf("0-%d", uploader.Size()-1)
391393
}
392394
setResponseHeaders(ctx.Resp, respHeaders)

tests/integration/api_packages_container_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,22 @@ func TestPackageContainer(t *testing.T) {
297297
SetHeader("Content-Range", "1-10")
298298
MakeRequest(t, req, http.StatusRequestedRangeNotSatisfiable)
299299

300-
contentRange := fmt.Sprintf("0-%d", len(blobContent)-1)
301-
req.SetHeader("Content-Range", contentRange)
300+
// first patch without Content-Range
301+
req = NewRequestWithBody(t, "PATCH", setting.AppURL+uploadURL[1:], bytes.NewReader(blobContent[:1])).
302+
AddTokenAuth(userToken)
303+
resp = MakeRequest(t, req, http.StatusAccepted)
304+
assert.NotEmpty(t, resp.Header().Get("Location"))
305+
assert.Equal(t, "0-0", resp.Header().Get("Range"))
306+
307+
// then send remaining content with Content-Range
308+
req = NewRequestWithBody(t, "PATCH", setting.AppURL+uploadURL[1:], bytes.NewReader(blobContent[1:])).
309+
SetHeader("Content-Range", fmt.Sprintf("1-%d", len(blobContent)-1)).
310+
AddTokenAuth(userToken)
302311
resp = MakeRequest(t, req, http.StatusAccepted)
303312

313+
contentRange := fmt.Sprintf("0-%d", len(blobContent)-1)
304314
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid"))
315+
assert.NotEmpty(t, resp.Header().Get("Location"))
305316
assert.Equal(t, contentRange, resp.Header().Get("Range"))
306317

307318
uploadURL = resp.Header().Get("Location")
@@ -311,6 +322,7 @@ func TestPackageContainer(t *testing.T) {
311322
resp = MakeRequest(t, req, http.StatusNoContent)
312323

313324
assert.Equal(t, uuid, resp.Header().Get("Docker-Upload-Uuid"))
325+
assert.Equal(t, uploadURL, resp.Header().Get("Location"))
314326
assert.Equal(t, contentRange, resp.Header().Get("Range"))
315327

316328
pbu, err = packages_model.GetBlobUploadByID(db.DefaultContext, uuid)

web_src/css/features/projects.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
flex-wrap: nowrap;
66
overflow: auto;
77
margin: 0 0.5em;
8+
min-height: max(calc(100vh - 400px), 300px);
89
max-height: calc(100vh - 120px);
910
}
1011

0 commit comments

Comments
 (0)