Fix the absolutely retarded single match crutch

This commit is contained in:
2025-11-20 15:12:01 +01:00
parent b35697d227
commit 079fc82ab9
2 changed files with 29 additions and 18 deletions

View File

@@ -508,7 +508,32 @@ func ExpandPattern(source, workdir, target string, filesOnly bool) (links []Link
}
// Normalize path to convert backslashes to forward slashes before pattern processing
source = NormalizePath(source, workdir)
if !strings.ContainsAny(source, "*?[{") {
info, statErr := os.Stat(source)
if statErr != nil {
if os.IsNotExist(statErr) {
LogInfo("Literal source %s does not exist, skipping", FormatSourcePath(source))
return nil, nil
}
return nil, fmt.Errorf("failed to stat literal source %s: %w", source, statErr)
}
if filesOnly && info.IsDir() {
LogInfo("Files-only mode: skipping directory %s", FormatSourcePath(source))
return nil, nil
}
return []LinkInstruction{
{
Source: source,
Target: target,
},
}, nil
}
static, pattern := doublestar.SplitPattern(source)
if static == "" || static == "." {
static = workdir
}
@@ -520,8 +545,6 @@ func ExpandPattern(source, workdir, target string, filesOnly bool) (links []Link
return nil, fmt.Errorf("error expanding pattern: %w", err)
}
singleMatch := len(files) == 1
for _, file := range files {
fullPath := filepath.Join(static, file)
@@ -531,18 +554,6 @@ func ExpandPattern(source, workdir, target string, filesOnly bool) (links []Link
continue
}
if singleMatch {
if info.IsDir() && filesOnly {
LogInfo("Files-only mode: skipping single matched directory %s", FormatSourcePath(fullPath))
continue
}
links = append(links, LinkInstruction{
Source: fullPath,
Target: target,
})
continue
}
if filesOnly && info.IsDir() {
LogInfo("Files-only mode: skipping directory %s", FormatSourcePath(fullPath))
continue