未验证 提交 2b285446 编写于 作者: M mstmdev 提交者: GitHub

Implement read link in the file query api (#233)

上级 d36b560f
...@@ -18,14 +18,14 @@ import ( ...@@ -18,14 +18,14 @@ import (
type fileApiHandler struct { type fileApiHandler struct {
logger log.Logger logger log.Logger
root http.FileSystem root http.Dir
chunkSize int64 chunkSize int64
checkpointCount int checkpointCount int
hash hashutil.Hash hash hashutil.Hash
} }
// NewFileApiHandlerFunc returns a gin.HandlerFunc that queries the file info // NewFileApiHandlerFunc returns a gin.HandlerFunc that queries the file info
func NewFileApiHandlerFunc(logger log.Logger, root http.FileSystem, chunkSize int64, checkpointCount int, hash hashutil.Hash) gin.HandlerFunc { func NewFileApiHandlerFunc(logger log.Logger, root http.Dir, chunkSize int64, checkpointCount int, hash hashutil.Hash) gin.HandlerFunc {
return (&fileApiHandler{ return (&fileApiHandler{
logger: logger, logger: logger,
root: root, root: root,
...@@ -146,7 +146,12 @@ func (h *fileApiHandler) readDir(f http.File, needHash bool, needCheckpoint bool ...@@ -146,7 +146,12 @@ func (h *fileApiHandler) readDir(f http.File, needHash bool, needCheckpoint bool
func (h *fileApiHandler) readlink(file fs.FileInfo) string { func (h *fileApiHandler) readlink(file fs.FileInfo) string {
if nsfs.IsSymlinkMode(file.Mode()) { if nsfs.IsSymlinkMode(file.Mode()) {
// TODO readlink path := filepath.Join(string(h.root), file.Name())
realPath, err := nsfs.Readlink(path)
if err == nil {
return realPath
}
h.logger.Error(err, "file api read link error => %s", path)
return file.Name() return file.Name()
} }
return "" return ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册