diff --git a/backend/utils/files/fileinfo.go b/backend/utils/files/fileinfo.go index 660d20fe6..ec3af09bf 100644 --- a/backend/utils/files/fileinfo.go +++ b/backend/utils/files/fileinfo.go @@ -102,6 +102,12 @@ func NewFileInfo(op FileOption) (*FileInfo, error) { if file.IsSymlink { file.LinkPath = GetSymlink(op.Path) + targetInfo, err := appFs.Stat(file.LinkPath) + if err != nil { + return nil, err + } + file.IsDir = targetInfo.IsDir() + file.Extension = filepath.Ext(file.LinkPath) } if op.Expand { if err := handleExpansion(file, op); err != nil { @@ -309,6 +315,12 @@ func (f *FileInfo) processFiles(files []FileSearchInfo, option FileOption) ([]*F } if isSymlink { file.LinkPath = GetSymlink(fPath) + targetInfo, err := file.Fs.Stat(file.LinkPath) + if err != nil { + return nil, err + } + file.IsDir = targetInfo.IsDir() + file.Extension = filepath.Ext(file.LinkPath) } if df.Size() > 0 { file.MimeType = GetMimeType(fPath) diff --git a/frontend/src/api/interface/file.ts b/frontend/src/api/interface/file.ts index 7329c9667..060ce7441 100644 --- a/frontend/src/api/interface/file.ts +++ b/frontend/src/api/interface/file.ts @@ -11,7 +11,7 @@ export namespace File { size: number; isDir: boolean; isSymlink: boolean; - linkPath: boolean; + linkPath: string; type: string; updateTime: string; modTime: string; diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index 0b98f3d38..2444f40c1 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -891,12 +891,12 @@ const openView = (item: File.File) => { compress: openDeCompress, text: () => openCodeEditor(item.path, item.extension), }; - - return actionMap[fileType] ? actionMap[fileType](item) : openCodeEditor(item.path, item.extension); + const path = item.isSymlink ? item.linkPath : item.path; + return actionMap[fileType] ? actionMap[fileType](item) : openCodeEditor(path, item.extension); }; const openPreview = (item: File.File, fileType: string) => { - filePreview.path = item.path; + filePreview.path = item.isSymlink ? item.linkPath : item.path; filePreview.name = item.name; filePreview.extension = item.extension; filePreview.fileType = fileType;