[#240] Fix native index page
All checks were successful
/ DCO (pull_request) Successful in 34s
/ Vulncheck (pull_request) Successful in 1m1s
/ Builds (pull_request) Successful in 1m7s
/ OCI image (pull_request) Successful in 1m26s
/ Lint (pull_request) Successful in 3m4s
/ Tests (pull_request) Successful in 1m17s
/ Integration tests (pull_request) Successful in 5m52s
All checks were successful
/ DCO (pull_request) Successful in 34s
/ Vulncheck (pull_request) Successful in 1m1s
/ Builds (pull_request) Successful in 1m7s
/ OCI image (pull_request) Successful in 1m26s
/ Lint (pull_request) Successful in 3m4s
/ Tests (pull_request) Successful in 1m17s
/ Integration tests (pull_request) Successful in 5m52s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
39cf4e508e
commit
acf6c33b27
2 changed files with 9 additions and 21 deletions
|
@ -76,13 +76,13 @@ func newListObjectsResponseNative(attrs map[string]string) ResponseObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNextDir(filepath, prefix string) string {
|
func getNextDir(filepath, prefix string) *string {
|
||||||
restPath := strings.Replace(filepath, prefix, "", 1)
|
restPath := strings.Replace(filepath, prefix, "", 1)
|
||||||
index := strings.Index(restPath, "/")
|
index := strings.Index(restPath, "/")
|
||||||
if index == -1 {
|
if index == -1 {
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
return restPath[:index]
|
return ptr(restPath[:index])
|
||||||
}
|
}
|
||||||
|
|
||||||
func lastPathElement(path string) string {
|
func lastPathElement(path string) string {
|
||||||
|
@ -143,7 +143,7 @@ func getParent(encPrefix string) string {
|
||||||
if slashIndex == -1 {
|
if slashIndex == -1 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return prefix[:slashIndex]
|
return prefix[:slashIndex+1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func urlencode(path string) string {
|
func urlencode(path string) string {
|
||||||
|
@ -259,7 +259,7 @@ func (h *Handler) getDirObjectsNative(ctx context.Context, bucketInfo *data.Buck
|
||||||
if _, ok := dirs[objExt.Object.FileName]; ok {
|
if _, ok := dirs[objExt.Object.FileName]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + urlencode(objExt.Object.FilePath)
|
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + "/" + urlencode(objExt.Object.FilePath)
|
||||||
dirs[objExt.Object.FileName] = struct{}{}
|
dirs[objExt.Object.FileName] = struct{}{}
|
||||||
} else {
|
} else {
|
||||||
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + "/" + objExt.Object.OID
|
objExt.Object.GetURL = "/get/" + bucketInfo.CID.EncodeToString() + "/" + objExt.Object.OID
|
||||||
|
@ -331,13 +331,13 @@ func (h *Handler) headDirObject(ctx context.Context, cnrID cid.ID, objID oid.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
dirname := getNextDir(attrs[object.AttributeFilePath], basePath)
|
dirname := getNextDir(attrs[object.AttributeFilePath], basePath)
|
||||||
if dirname == "" {
|
if dirname == nil {
|
||||||
return newListObjectsResponseNative(attrs), nil
|
return newListObjectsResponseNative(attrs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseObject{
|
return ResponseObject{
|
||||||
FileName: dirname,
|
FileName: *dirname,
|
||||||
FilePath: basePath + dirname,
|
FilePath: basePath + *dirname,
|
||||||
IsDir: true,
|
IsDir: true,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,27 +56,15 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ $parentPrefix := getParent .Prefix }}
|
{{ $parentPrefix := getParent .Prefix }}
|
||||||
{{if $parentPrefix }}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
⮐<a href="/get/{{$container}}{{ urlencode $parentPrefix }}/">..</a>
|
⮐<a href="/get/{{$container}}/{{ urlencode $parentPrefix }}">..</a>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
⮐<a href="/get/{{$container}}/">..</a>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
{{range .Objects}}
|
{{range .Objects}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue