From c0c78f6b36255ae4834e279a698716e0f1a4fb99 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 29 Mar 2016 16:42:18 -0700 Subject: [PATCH 1/2] Not deleting files if the number of files is less than max files --- client/driver/logging/rotator.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/driver/logging/rotator.go b/client/driver/logging/rotator.go index 93a4be4f0..d846d5e81 100644 --- a/client/driver/logging/rotator.go +++ b/client/driver/logging/rotator.go @@ -238,6 +238,12 @@ 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)) From 0c9a5dcb8b4cf4000215a5a922d9e5e853c42423 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 29 Mar 2016 17:30:43 -0700 Subject: [PATCH 2/2] Fixing comments --- client/driver/logging/rotator.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/driver/logging/rotator.go b/client/driver/logging/rotator.go index d846d5e81..5fbe218b3 100644 --- a/client/driver/logging/rotator.go +++ b/client/driver/logging/rotator.go @@ -238,7 +238,7 @@ func (f *FileRotator) purgeOldFiles() { } } - // not continuing to delete files if the number of files is not more + // Not continuing to delete files if the number of files is not more // than MaxFiles if len(fIndexes) <= f.MaxFiles { continue @@ -247,8 +247,7 @@ func (f *FileRotator) purgeOldFiles() { // 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)