Skip to content

Commit

Permalink
fix: delete unused persist file
Browse files Browse the repository at this point in the history
  • Loading branch information
st0nie committed Jan 10, 2025
1 parent 87be4b0 commit 03c409c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,22 @@ func newControlPlane(log *logrus.Logger, bpf interface{}, dnsCache map[string]*c
tagToNodeList[tag] = append(tagToNodeList[tag], nodes...)
}
}

// Delete all files in persist.d that are not in tagToNodeList
files, err := os.ReadDir(filepath.Join(filepath.Dir(cfgFile), "persist.d"))
if err != nil && !os.IsNotExist(err) {
return nil, err
}
for _, file := range files {
tag := strings.TrimSuffix(file.Name(), ".sub")
if _, ok := tagToNodeList[tag]; !ok {
err := os.Remove(filepath.Join(filepath.Dir(cfgFile), "persist.d", file.Name()))
if err != nil {
return nil, err
}
}
}

if len(tagToNodeList) == 0 {
if resolvingfailed {
log.Warnln("No node found because all subscription resolving failed.")
Expand Down

0 comments on commit 03c409c

Please sign in to comment.