diff options
author | Simon Rettberg | 2018-05-16 13:08:44 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-05-16 13:08:44 +0200 |
commit | e519e8edee76b0861f0684823f8f2a0cb9938ff3 (patch) | |
tree | 0380ebc565c0c17af8671b8f965c5015f8c16cf3 /src/main/java/org/openslx/filetransfer/util/ChunkList.java | |
parent | Add PrioThreadFactory (diff) | |
download | master-sync-shared-e519e8edee76b0861f0684823f8f2a0cb9938ff3.tar.gz master-sync-shared-e519e8edee76b0861f0684823f8f2a0cb9938ff3.tar.xz master-sync-shared-e519e8edee76b0861f0684823f8f2a0cb9938ff3.zip |
More speedup: LZ4 and empty chunk detection
Diffstat (limited to 'src/main/java/org/openslx/filetransfer/util/ChunkList.java')
-rw-r--r-- | src/main/java/org/openslx/filetransfer/util/ChunkList.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/org/openslx/filetransfer/util/ChunkList.java b/src/main/java/org/openslx/filetransfer/util/ChunkList.java index 11f64e8..91d6f1e 100644 --- a/src/main/java/org/openslx/filetransfer/util/ChunkList.java +++ b/src/main/java/org/openslx/filetransfer/util/ChunkList.java @@ -69,8 +69,14 @@ public class ChunkList if ( index >= allChunks.size() ) break; if ( sum != null ) { - if ( allChunks.get( index ).setSha1Sum( sum ) && firstNew == -1 ) { - firstNew = index; + FileChunk chunk = allChunks.get( index ); + if ( chunk.setSha1Sum( sum ) ) { + if ( firstNew == -1 ) { + firstNew = index; + } + if ( chunk.status == ChunkStatus.MISSING && Arrays.equals( FileChunk.NULL_BLOCK_SHA1, sum ) ) { + markMissingAsComplete( index ); + } } if ( !hasChecksum ) { hasChecksum = true; @@ -473,4 +479,16 @@ public class ChunkList return true; } + /** + * Returns true if the last chunk is exactly 16MiB and all zeros + * @return + */ + public boolean lastChunkIsZero() + { + if ( allChunks.isEmpty() ) + return false; + FileChunk chunk = allChunks.get( allChunks.size() - 1 ); + return chunk.sha1sum != null && Arrays.equals( FileChunk.NULL_BLOCK_SHA1, chunk.sha1sum ); + } + } |