From a53fff2416fff04f79d6ec51810687f88d57e6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:37:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=AF=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E8=A2=AB=E8=AF=86=E5=88=AB=E4=B8=BA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#6400)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #5879 --- backend/utils/files/fileinfo.go | 12 ++++++++++++ frontend/src/api/interface/file.ts | 2 +- frontend/src/views/host/file-management/index.vue | 6 +++--- 3 files changed, 16 insertions(+), 4 deletions(-) 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;