public void cleanCache ( File dir , Formatter sbuff , boolean isRoot ) { long now = System . currentTimeMillis ( ) ; File [ ] files = dir . listFiles ( ) ; if ( files == null ) { throw new IllegalStateException ( "DiskCache2: not a directory or I/O error on dir=" + dir . getAbsolutePath ( ) ) ; } // check for empty directory if ( ! isRoot && ( files . length == 0 ) ) { long duration = now - dir . lastModified ( ) ; duration /= 1000 * 60 ; // minutes if ( duration > persistMinutes ) { boolean ok = dir . delete ( ) ; if ( ! ok ) cacheLog . error ( "Unable to delete file " + dir . getAbsolutePath ( ) ) ; if ( sbuff != null ) sbuff . format ( " deleted %s %s lastModified= %s%n" , ok , dir . getPath ( ) , CalendarDate . of ( dir . lastModified ( ) ) ) ; } return ; } // check for expired files for ( File file : files ) { if ( file . isDirectory ( ) ) { cleanCache ( file , sbuff , false ) ; } else { long duration = now - file . lastModified ( ) ; duration /= 1000 * 60 ; // minutes if ( duration > persistMinutes ) { boolean ok = file . delete ( ) ; if ( ! ok ) cacheLog . error ( "Unable to delete file " + file . getAbsolutePath ( ) ) ; if ( sbuff != null ) sbuff . format ( " deleted %s %s lastModified= %s%n" , ok , file . getPath ( ) , CalendarDate . of ( file . lastModified ( ) ) ) ; } } } }
Remove any files or directories whose last modified time greater than persistMinutes