public void sweepFile ( long now , Path p ) throws Exception { if ( p == null ) { return ; } long expiry = getExpiryFromFilename ( p . getFileName ( ) . toString ( ) ) ; // files with 0 expiry never expire if ( expiry > 0 && ( ( now - expiry ) >= ( 5 * TimeUnit . SECONDS . toMillis ( gracePeriodSec ) ) ) ) { Files . deleteIfExists ( p ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Sweep deleted " + p . getFileName ( ) ) ; } } }
Check to see if the expiry on the file is very old and delete the file if so . Old means that it expired at least 5 gracePeriods ago .