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 {
116116
117117 async _deleteFiles ( ) {
118118 const filesToDelete = [ ] ;
119- let fileNumber = 0 ;
119+ // Only count backups - start at file 1 to ignore current file
120+ let fileNumber = 1 ;
120121 let bytesTotal = 0 ;
121122 for ( ; ; fileNumber ++ ) {
122123 const name = this . _getFileName ( fileNumber , true ) ;
123124 try {
124125 const result = await fs . stat ( name ) ;
125126 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 ) ) {
127128 filesToDelete . push ( name ) ;
128129 }
129130 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments