Fix deleting by not deleting at all
This commit is contained in:
@@ -281,8 +281,8 @@ func ParseYAMLFile(filename, workdir string) ([]LinkInstruction, error) {
|
|||||||
config.Links = instructions
|
config.Links = instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
toRemove := []int{}
|
expanded := []LinkInstruction{}
|
||||||
for i, link := range config.Links {
|
for _, link := range config.Links {
|
||||||
if strings.Contains(link.Source, "*") {
|
if strings.Contains(link.Source, "*") {
|
||||||
LogSource("Expanding wildcard source %s in YAML file %s", link.Source, filename)
|
LogSource("Expanding wildcard source %s in YAML file %s", link.Source, filename)
|
||||||
newlinks, err := ExpandWildcard(link.Source, workdir, link.Target)
|
newlinks, err := ExpandWildcard(link.Source, workdir, link.Target)
|
||||||
@@ -297,17 +297,14 @@ func ParseYAMLFile(filename, workdir string) ([]LinkInstruction, error) {
|
|||||||
}
|
}
|
||||||
LogInfo("Expanded wildcard source %s in YAML file %s to %d links",
|
LogInfo("Expanded wildcard source %s in YAML file %s to %d links",
|
||||||
FormatSourcePath(link.Source), FormatSourcePath(filename), len(newlinks))
|
FormatSourcePath(link.Source), FormatSourcePath(filename), len(newlinks))
|
||||||
config.Links = append(config.Links, newlinks...)
|
expanded = append(expanded, newlinks...)
|
||||||
toRemove = append(toRemove, i)
|
} else {
|
||||||
|
expanded = append(expanded, link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := len(toRemove) - 1; i >= 0; i-- {
|
for i := range expanded {
|
||||||
config.Links = slices.Delete(config.Links, toRemove[i], 1)
|
link := &expanded[i]
|
||||||
}
|
|
||||||
|
|
||||||
for i := range config.Links {
|
|
||||||
link := &config.Links[i]
|
|
||||||
|
|
||||||
link.Tidy()
|
link.Tidy()
|
||||||
link.Source, _ = ConvertHome(link.Source)
|
link.Source, _ = ConvertHome(link.Source)
|
||||||
@@ -316,12 +313,12 @@ func ParseYAMLFile(filename, workdir string) ([]LinkInstruction, error) {
|
|||||||
link.Target = NormalizePath(link.Target, workdir)
|
link.Target = NormalizePath(link.Target, workdir)
|
||||||
|
|
||||||
// If Delete is true, Force must also be true
|
// If Delete is true, Force must also be true
|
||||||
if config.Links[i].Delete {
|
if link.Delete {
|
||||||
config.Links[i].Force = true
|
link.Force = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config.Links, nil
|
return expanded, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExpandWildcard(source, workdir, target string) (links []LinkInstruction, err error) {
|
func ExpandWildcard(source, workdir, target string) (links []LinkInstruction, err error) {
|
||||||
|
Reference in New Issue
Block a user