private void purgeDirectories ( FileSystem fs , Path root ) throws IOException { DirectoryTraversal traversal = DirectoryTraversal . directoryRetriever ( Arrays . asList ( root ) , fs , directoryTraversalThreads , directoryTraversalShuffle ) ; String prefix = root . toUri ( ) . getPath ( ) ; FileStatus dir ; while ( ( dir = traversal . next ( ) ) != DirectoryTraversal . FINISH_TOKEN ) { Path dirPath = dir . getPath ( ) ; if ( dirPath . toUri ( ) . getPath ( ) . endsWith ( RaidNode . HAR_SUFFIX ) ) { continue ; } String dirStr = dirPath . toUri ( ) . getPath ( ) ; if ( ! dirStr . startsWith ( prefix ) ) { continue ; } entriesProcessed . incrementAndGet ( ) ; String src = dirStr . replaceFirst ( prefix , "" ) ; if ( src . length ( ) == 0 ) continue ; Path srcPath = new Path ( src ) ; if ( ! fs . exists ( srcPath ) ) { performDelete ( fs , dirPath , true ) ; } } }
Traverse the parity destination directory removing directories that no longer existing in the source .