Browse Source

fix: 解决软连接被识别为文件问题 (#6400)

Refs #5879
pull/6404/head
3 months ago committed by GitHub
parent
commit
a53fff2416
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      backend/utils/files/fileinfo.go
  2. 2
      frontend/src/api/interface/file.ts
  3. 6
      frontend/src/views/host/file-management/index.vue

12
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)

2
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;

6
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;

Loading…
Cancel
Save