Skip to content

Commit 2b28544

Browse files
authored
Implement read link in the file query api (#233)
1 parent d36b560 commit 2b28544

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

server/handler/file_api_handler.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import (
1818

1919
type fileApiHandler struct {
2020
logger log.Logger
21-
root http.FileSystem
21+
root http.Dir
2222
chunkSize int64
2323
checkpointCount int
2424
hash hashutil.Hash
2525
}
2626

2727
// NewFileApiHandlerFunc returns a gin.HandlerFunc that queries the file info
28-
func NewFileApiHandlerFunc(logger log.Logger, root http.FileSystem, chunkSize int64, checkpointCount int, hash hashutil.Hash) gin.HandlerFunc {
28+
func NewFileApiHandlerFunc(logger log.Logger, root http.Dir, chunkSize int64, checkpointCount int, hash hashutil.Hash) gin.HandlerFunc {
2929
return (&fileApiHandler{
3030
logger: logger,
3131
root: root,
@@ -146,7 +146,12 @@ func (h *fileApiHandler) readDir(f http.File, needHash bool, needCheckpoint bool
146146

147147
func (h *fileApiHandler) readlink(file fs.FileInfo) string {
148148
if nsfs.IsSymlinkMode(file.Mode()) {
149-
// TODO readlink
149+
path := filepath.Join(string(h.root), file.Name())
150+
realPath, err := nsfs.Readlink(path)
151+
if err == nil {
152+
return realPath
153+
}
154+
h.logger.Error(err, "file api read link error => %s", path)
150155
return file.Name()
151156
}
152157
return ""

0 commit comments

Comments
 (0)