deleteStaleData: rework files looping
Make gosec happy as it complains about excessive nesting (nestingReduce)
@@ -1109,7 +1109,9 @@ func (dn *Daemon) deleteStaleData(oldIgnConfig, newIgnConfig *ign3types.Config)
}
for _, f := range oldIgnConfig.Storage.Files {
- if _, ok := newFileSet[f.Path]; !ok {
+ if _, ok := newFileSet[f.Path]; ok {
+ continue
+ }
if _, err := os.Stat(noOrigFileStampName(f.Path)); err == nil {
if err := os.Remove(noOrigFileStampName(f.Path)); err != nil {
return errors.Wrapf(err, "deleting noorig file stamp %q: %v", noOrigFileStampName(f.Path), err)
@@ -1165,7 +1167,6 @@ func (dn *Daemon) deleteStaleData(oldIgnConfig, newIgnConfig *ign3types.Config)
}
glog.Infof("Removed stale file %q", f.Path)
}
- }
newUnitSet := make(map[string]struct{})
newDropinSet := make(map[string]struct{})
