Skip to content

Commit

Permalink
Fix link physical address response to contain full path
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har committed Oct 11, 2023
1 parent aa099d0 commit 5e91912
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion esti/lakectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestLakectlPreSignUpload(t *testing.T) {

filePath := "ro_1k.1"
vars["FILE_PATH"] = filePath
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload_pre_signed", vars)
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload", vars)
}

func TestLakectlCommit(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request,
}

writeTime := time.Now()
physicalAddress, addressType := normalizePhysicalAddress(repo.StorageNamespace, swag.StringValue(body.Staging.PhysicalAddress))
fullPhysicalAddress := swag.StringValue(body.Staging.PhysicalAddress)
physicalAddress, addressType := normalizePhysicalAddress(repo.StorageNamespace, fullPhysicalAddress)

if addressType == catalog.AddressTypeRelative {
// if the address is in the storage namespace, verify it has been saved for linking
err = c.Catalog.VerifyLinkAddress(ctx, repository, physicalAddress)
Expand Down Expand Up @@ -403,7 +405,7 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request,
Mtime: entry.CreationDate.Unix(),
Path: entry.Path,
PathType: entryTypeObject,
PhysicalAddress: entry.PhysicalAddress,
PhysicalAddress: fullPhysicalAddress,
SizeBytes: swag.Int64(entry.Size),
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/api/helpers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ func clientUploadPreSignHelper(ctx context.Context, client apigen.ClientWithResp
return nil, fmt.Errorf("link object to backing store: %w", err)
}
if linkResp.JSON200 != nil {
objStat := *linkResp.JSON200
// this is a workaround for the fact that the API does not return the full physical address
objStat.PhysicalAddress = preSignURL
return &objStat, nil
return linkResp.JSON200, nil
}
if linkResp.JSON409 != nil {
return nil, ErrConflict
Expand Down

0 comments on commit 5e91912

Please sign in to comment.