File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -116,14 +116,15 @@ class FileRotator extends EventEmitter {
116
116
117
117
async _deleteFiles ( ) {
118
118
const filesToDelete = [ ] ;
119
- let fileNumber = 0 ;
119
+ // Only count backups - start at file 1 to ignore current file
120
+ let fileNumber = 1 ;
120
121
let bytesTotal = 0 ;
121
122
for ( ; ; fileNumber ++ ) {
122
123
const name = this . _getFileName ( fileNumber , true ) ;
123
124
try {
124
125
const result = await fs . stat ( name ) ;
125
126
bytesTotal += result . size ;
126
- if ( ( this . _totalSize && bytesTotal > this . _totalSize ) || ( this . _totalFiles && fileNumber > this . _totalFiles ) ) {
127
+ if ( ( this . _totalSize && bytesTotal > this . _totalSize ) || ( this . _totalFiles && fileNumber >= this . _totalFiles ) ) {
127
128
filesToDelete . push ( name ) ;
128
129
}
129
130
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments