[no-relnote] Check created outside of create loop

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2024-10-22 11:53:28 +02:00 committed by Christopher Desiniotis
parent d78868cd31
commit fa59d12973
No known key found for this signature in database
GPG Key ID: 603C8E544D789A89

View File

@ -95,29 +95,30 @@ func (m command) run(c *cli.Context, cfg *config) error {
created := make(map[string]bool) created := make(map[string]bool)
for _, l := range cfg.links.Value() { for _, l := range cfg.links.Value() {
if created[l] {
m.logger.Debugf("Link %v already processed", l)
continue
}
parts := strings.Split(l, "::") parts := strings.Split(l, "::")
if len(parts) != 2 { if len(parts) != 2 {
m.logger.Warningf("Invalid link specification %v", l) m.logger.Warningf("Invalid link specification %v", l)
continue continue
} }
err := m.createLink(created, cfg.hostRoot, containerRoot, parts[0], parts[1]) err := m.createLink(cfg.hostRoot, containerRoot, parts[0], parts[1])
if err != nil { if err != nil {
m.logger.Warningf("Failed to create link %v: %v", parts, err) m.logger.Warningf("Failed to create link %v: %v", parts, err)
} }
created[l] = true
} }
return nil return nil
} }
func (m command) createLink(created map[string]bool, hostRoot string, containerRoot string, target string, link string) error { func (m command) createLink(hostRoot string, containerRoot string, target string, link string) error {
linkPath, err := changeRoot(hostRoot, containerRoot, link) linkPath, err := changeRoot(hostRoot, containerRoot, link)
if err != nil { if err != nil {
m.logger.Warningf("Failed to resolve path for link %v relative to %v: %v", link, containerRoot, err) m.logger.Warningf("Failed to resolve path for link %v relative to %v: %v", link, containerRoot, err)
} }
if created[linkPath] {
m.logger.Debugf("Link %v already created", linkPath)
return nil
}
targetPath, err := changeRoot(hostRoot, "/", target) targetPath, err := changeRoot(hostRoot, "/", target)
if err != nil { if err != nil {