Fix files being linked as folders

This commit is contained in:
2025-04-15 20:28:49 +02:00
parent 8da1f023a7
commit 3f7fd36f84
2 changed files with 28 additions and 12 deletions

View File

@@ -337,21 +337,21 @@ func ExpandPattern(source, workdir, target string) (links []LinkInstruction, err
}
for _, file := range files {
if len(files) == 1 {
// Special case: if there is only one file
// This should only ever happen if our source is a path (and not a glob!)
// And our target is a path
// ...but it will also happen if the source IS a glob and it happens to match ONE file
// I think that should happen rarely enough to not be an issue...
links = append(links, LinkInstruction{
Source: filepath.Join(static, file),
Target: target,
})
continue
}
if info, err := os.Stat(file); err == nil && info.IsDir() {
// We don't care about matched directories
// We want files within them
if len(files) == 1 {
// Special case: if there is only one file, and it's a directory
// This should only ever happen if our source is a path (and not a glob!)
// And our target is a path, a directory
// ...but it will also happen if the source IS a glob and it happens to match ONE directory
// I think that should happen rarely enough to not be an issue...
links = append(links, LinkInstruction{
Source: filepath.Join(static, file),
Target: target,
})
continue
}
LogInfo("Skipping directory %s", file)
continue
}