* Start the verification: remove files that are not in the DHT yet and remove files that equal to the
* ones in the DHT.
*/
Set<File> toDelete = new HashSet<File>();
for (File file : fileBuffer) {
FileTaste fileTaste = null;
for (FileTaste syncFile : syncFiles) {
if (syncFile.getFile().equals(file)) {
fileTaste = syncFile;
break;
}
}
if (fileTaste == null) {
// don't modify a file that is not in the DHT
toDelete.add(file);
} else {
try {
// check for MD5 hashes, if equal, skip the file
byte[] fileHash = EncryptionUtil.generateMD5Hash(file);
if (H2HEncryptionUtil.compareMD5(fileHash, fileTaste.getMd5())) {
// hashes are equal, no need to upload it to the DHT
toDelete.add(file);
}
} catch (IOException e) {
logger.warn("Could not generate the MD5 hash of the file to be able to compare against the file taste.");