static private boolean sameFile ( FileSystem srcfs , FileStatus srcstatus , FileSystem dstfs , Path dstpath , boolean skipCRCCheck ) throws IOException { FileStatus dststatus ; try { dststatus = dstfs . getFileStatus ( dstpath ) ; } catch ( FileNotFoundException fnfe ) { return false ; } //same length? if ( srcstatus . getLen ( ) != dststatus . getLen ( ) ) { return false ; } if ( skipCRCCheck ) { LOG . debug ( "Skipping CRC Check" ) ; return true ; } //get src checksum final FileChecksum srccs ; try { srccs = srcfs . getFileChecksum ( srcstatus . getPath ( ) ) ; } catch ( FileNotFoundException fnfe ) { /* * Two possible cases: * (1) src existed once but was deleted between the time period that * srcstatus was obtained and the try block above. * (2) srcfs does not support file checksum and (incorrectly) throws * FNFE, e.g. some previous versions of HftpFileSystem. * For case (1), it is okay to return true since src was already deleted. * For case (2), true should be returned. */ return true ; } //compare checksums try { final FileChecksum dstcs = dstfs . getFileChecksum ( dststatus . getPath ( ) ) ; //return true if checksum is not supported //(i.e. some of the checksums is null) return srccs == null || dstcs == null || srccs . equals ( dstcs ) ; } catch ( FileNotFoundException fnfe ) { return false ; } }
Check whether the contents of src and dst are the same .