fix: Fix the problem of eliminating file exceptions in the backup dir… (#8596)

This commit is contained in:
ssongliu 2025-05-11 22:57:56 +08:00 committed by GitHub
parent 633dbe1aec
commit 55bab2e255
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -732,8 +732,7 @@ func (f FileOp) TarGzCompressPro(withDir bool, src, dst, secret, exclusionRules
if _, ok := exMap[exclude]; ok {
continue
}
exStr += " --exclude "
exStr += exclude
exStr += fmt.Sprintf(" --exclude '%s'", exclude)
exMap[exclude] = struct{}{}
}

View file

@ -80,6 +80,7 @@ func HandleTar(sourceDir, targetDir, name, exclusionRules string, secret string)
}
}
exMap := make(map[string]struct{})
excludes := strings.Split(exclusionRules, ",")
excludeRules := ""
excludes = append(excludes, "*.sock")
@ -87,7 +88,11 @@ func HandleTar(sourceDir, targetDir, name, exclusionRules string, secret string)
if len(exclude) == 0 {
continue
}
excludeRules += " --exclude " + exclude
if _, ok := exMap[exclude]; ok {
continue
}
excludeRules += fmt.Sprintf(" --exclude '%s'", exclude)
exMap[exclude] = struct{}{}
}
path := ""
if strings.Contains(sourceDir, "/") {