Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#323 from tbs60/dev_tming
Browse files Browse the repository at this point in the history
Dev tming
  • Loading branch information
tming authored Nov 26, 2024
2 parents d9153ac + eee021b commit 9a92a3b
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/backend/booster/bk_dist/common/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func GetFileInfo(fs []string, mustexisted bool, notdir bool, statbysearchdir boo
}

// query
hasUnknown := false
tempis := make(map[string]*Info, len(notfound))
for _, notf := range notfound {
tempf := notf
Expand Down Expand Up @@ -300,10 +301,11 @@ func GetFileInfo(fs []string, mustexisted bool, notdir bool, statbysearchdir boo

// 根据当前文件属性,给上一次的文件属性赋值
if loopagain { // 需要等链接的属性
i.FileType = LinkFile // 先假设是指向普通文件的链接
i.FileType = Unknown // 先假设是指向普通文件的链接
if oldi != nil {
oldi.FileType = LinkFile
blog.Infof("common util: set %s to LinkFile by assume", oldi.filePath)
oldi.FileType = Unknown
blog.Infof("common util: set %s to Unknown by assume", oldi.filePath)
hasUnknown = true
}
} else {
if i.Basic().IsDir() {
Expand All @@ -330,6 +332,24 @@ func GetFileInfo(fs []string, mustexisted bool, notdir bool, statbysearchdir boo
}
}

// 如果有多重链接,需要根据最终文件属性赋值
if hasUnknown {
// 用后面的链接属性更新到前面
finalLinkType := Unknown
for index := len(is) - 1; index >= 0; index-- {
if is[index].FileType == LinkFile || is[index].FileType == LinkDir {
finalLinkType = is[index].FileType
continue
}

if is[index].FileType == Unknown {
is[index].FileType = finalLinkType
blog.Infof("common util: adjust %s FileType to %d", is[index].filePath, finalLinkType)
continue
}
}
}

// write
go func(tempis *map[string]*Info) {
fileInfoCacheLock.Lock()
Expand Down

0 comments on commit 9a92a3b

Please sign in to comment.