forked from Qortal/qortal
Optimized onNetworkGetArbitraryDataFileListMessage() to remove duplicate calls to Files.exists()
This commit is contained in:
parent
6e91157dcf
commit
6423d5e474
@ -440,26 +440,34 @@ public class ArbitraryDataFileListManager {
|
|||||||
if (metadataHash != null) {
|
if (metadataHash != null) {
|
||||||
arbitraryDataFile.setMetadataHash(metadataHash);
|
arbitraryDataFile.setMetadataHash(metadataHash);
|
||||||
|
|
||||||
|
// Assume all chunks exists, unless one can't be found below
|
||||||
|
allChunksExist = true;
|
||||||
|
|
||||||
// If we have the metadata file, add its hash
|
// If we have the metadata file, add its hash
|
||||||
if (arbitraryDataFile.getMetadataFile().exists()) {
|
if (arbitraryDataFile.getMetadataFile().exists()) {
|
||||||
hashes.add(arbitraryDataFile.getMetadataHash());
|
hashes.add(arbitraryDataFile.getMetadataHash());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// Check if we have all the chunks (and the metadata file)
|
allChunksExist = false;
|
||||||
allChunksExist = arbitraryDataFile.allChunksExist();
|
}
|
||||||
|
|
||||||
for (ArbitraryDataFileChunk chunk : arbitraryDataFile.getChunks()) {
|
for (ArbitraryDataFileChunk chunk : arbitraryDataFile.getChunks()) {
|
||||||
if (chunk.exists()) {
|
if (chunk.exists()) {
|
||||||
hashes.add(chunk.getHash());
|
hashes.add(chunk.getHash());
|
||||||
//LOGGER.trace("Added hash {}", chunk.getHash58());
|
//LOGGER.trace("Added hash {}", chunk.getHash58());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.debug("Couldn't add hash {} because it doesn't exist", chunk.getHash58());
|
LOGGER.trace("Couldn't add hash {} because it doesn't exist", chunk.getHash58());
|
||||||
|
allChunksExist = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This transaction has no chunks, so include the complete file if we have it
|
// This transaction has no chunks, so include the complete file if we have it
|
||||||
if (arbitraryDataFile.exists()) {
|
if (arbitraryDataFile.exists()) {
|
||||||
hashes.add(arbitraryDataFile.getHash());
|
hashes.add(arbitraryDataFile.getHash());
|
||||||
|
allChunksExist = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
allChunksExist = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user