mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 02:45:42 +03:00
Merge pull request #1006 from hashicorp/guard-purge-files
Not deleting files if the number of files is less than max files
This commit is contained in:
@@ -238,11 +238,16 @@ func (f *FileRotator) purgeOldFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
// Not continuing to delete files if the number of files is not more
|
||||
// than MaxFiles
|
||||
if len(fIndexes) <= f.MaxFiles {
|
||||
continue
|
||||
}
|
||||
|
||||
// Sorting the file indexes so that we can purge the older files and keep
|
||||
// only the number of files as configured by the user
|
||||
sort.Sort(sort.IntSlice(fIndexes))
|
||||
var toDelete []int
|
||||
toDelete = fIndexes[0 : len(fIndexes)-f.MaxFiles]
|
||||
toDelete := fIndexes[0 : len(fIndexes)-f.MaxFiles]
|
||||
for _, fIndex := range toDelete {
|
||||
fname := filepath.Join(f.path, fmt.Sprintf("%s.%d", f.baseFileName, fIndex))
|
||||
os.RemoveAll(fname)
|
||||
|
||||
Reference in New Issue
Block a user