private FileDetails purgeOldestFile ( ) { debugListLL ( "prepurgeOldestFile" ) ; debugListHM ( "prepurgeOldestFile" ) ; FileDetails returnFD = getOldestInactive ( ) ; if ( debugLogger . isLoggable ( Level . FINE ) && LogRepositoryBaseImpl . isDebugEnabled ( ) ) { debugLogger . logp ( Level . FINE , thisClass , "purgeOldestFile" , "oldestInactive: " + ( ( returnFD == null ) ? "None" : returnFD . file . getPath ( ) ) ) ; } if ( returnFD == null ) return null ; if ( debugLogger . isLoggable ( Level . FINE ) && LogRepositoryBaseImpl . isDebugEnabled ( ) ) { debugLogger . logp ( Level . FINE , thisClass , "purgeOldestFile" , "fileList size before remove: " + fileList . size ( ) ) ; } if ( debugLogger . isLoggable ( Level . FINE ) && LogRepositoryBaseImpl . isDebugEnabled ( ) ) { debugLogger . logp ( Level . FINE , thisClass , "purgeOldestFile" , "fileList size after remove: " + fileList . size ( ) ) ; } if ( AccessHelper . deleteFile ( returnFD . file ) ) { fileList . remove ( returnFD ) ; totalSize -= returnFD . size ; if ( debugLogger . isLoggable ( Level . FINE ) && LogRepositoryBaseImpl . isDebugEnabled ( ) ) { debugLogger . logp ( Level . FINE , thisClass , "purgeOldestFile" , "delete: " + returnFD . file . getName ( ) ) ; } decrementFileCount ( returnFD . file ) ; notifyOfFileAction ( LogEventListener . EVENTTYPEDELETE ) ; // F004324 } else { // Assume the list is out of sync. if ( debugLogger . isLoggable ( Level . FINE ) && LogRepositoryBaseImpl . isDebugEnabled ( ) ) { debugLogger . logp ( Level . FINE , thisClass , "purgeOldestFile" , "Failed to delete file: " + returnFD . file . getPath ( ) ) ; } initFileList ( true ) ; returnFD = null ; } debugListLL ( "postpurgeOldestFile" ) ; return returnFD ; }
Removes the oldest file from the repository . This method has logic to avoid removing currently active files This method should be called with a lock on filelist already attained