From 34587a08c0c107096969131f4e191d0eb3ec5cf3 Mon Sep 17 00:00:00 2001 From: Jalileh Date: Tue, 28 Jan 2025 17:15:32 +0100 Subject: [PATCH] reverted a broken ai refractor, improved previous method of file checking Now symlink directories with . wont break anything. --- pkg/util/fileutil/fileutil.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/util/fileutil/fileutil.go b/pkg/util/fileutil/fileutil.go index b5bbfbb1b..bf1cb3f7a 100644 --- a/pkg/util/fileutil/fileutil.go +++ b/pkg/util/fileutil/fileutil.go @@ -38,12 +38,19 @@ const ( func WinSymlinkDir(path string, bits os.FileMode) bool { // Windows compatibility layer doesn't expose symlink target type through fileInfo - // so we need to check file attributes and extension patterns + // so we need to over-engineer a bit isFileSymlink := func(filepath string) bool { - if len(filepath) == 0 { - return false + Length, dirIndex := len(filepath)-1, strings.LastIndex(filepath, "\\") + for i := Length; i > dirIndex; i-- { + if filepath[i] == '.' { + // here to catch directories like .shared / .config + if i-1 == dirIndex { + break + } + return true + } } - return strings.LastIndex(filepath, ".") > strings.LastIndex(filepath, "/") + return false } flags := uint32(bits >> 12)