private static PropertyMap getChecksums ( final File file , final java . io . File fileOnDisk ) throws IOException { final PropertyMap propertiesWithChecksums = new PropertyMap ( ) ; Folder parentFolder = file . getParent ( ) ; String checksums = null ; while ( parentFolder != null && checksums == null ) { checksums = parentFolder . getEnabledChecksums ( ) ; parentFolder = parentFolder . getParent ( ) ; } if ( checksums == null ) { checksums = Settings . DefaultChecksums . getValue ( ) ; } // New, very fast xxHash default checksum, will always be calculated propertiesWithChecksums . put ( StructrApp . key ( File . class , "checksum" ) , FileHelper . getChecksum ( fileOnDisk ) ) ; if ( StringUtils . contains ( checksums , "crc32" ) ) { propertiesWithChecksums . put ( StructrApp . key ( File . class , "crc32" ) , FileHelper . getCRC32Checksum ( fileOnDisk ) ) ; } if ( StringUtils . contains ( checksums , "md5" ) ) { propertiesWithChecksums . put ( StructrApp . key ( File . class , "md5" ) , FileHelper . getMD5Checksum ( file ) ) ; } if ( StringUtils . contains ( checksums , "sha1" ) ) { propertiesWithChecksums . put ( StructrApp . key ( File . class , "sha1" ) , FileHelper . getSHA1Checksum ( file ) ) ; } if ( StringUtils . contains ( checksums , "sha512" ) ) { propertiesWithChecksums . put ( StructrApp . key ( File . class , "sha512" ) , FileHelper . getSHA512Checksum ( file ) ) ; } return propertiesWithChecksums ; }
Calculate checksums that are configured in settings of parent folder .