diff options
author | Simon Rettberg | 2016-01-28 17:02:31 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-01-28 17:02:31 +0100 |
commit | 9c41de54bb7c80349c45d34bd53e734ee3e88b5b (patch) | |
tree | cf4799106834bd694361fdecb2e83c26caf24933 /src/main/java/org/openslx/filetransfer/util/FileChunk.java | |
parent | [thrift] Add UserInfo comparator (diff) | |
download | master-sync-shared-9c41de54bb7c80349c45d34bd53e734ee3e88b5b.tar.gz master-sync-shared-9c41de54bb7c80349c45d34bd53e734ee3e88b5b.tar.xz master-sync-shared-9c41de54bb7c80349c45d34bd53e734ee3e88b5b.zip |
Make hashing classes more robust, report complete blocks without hash info as hashing
Diffstat (limited to 'src/main/java/org/openslx/filetransfer/util/FileChunk.java')
-rw-r--r-- | src/main/java/org/openslx/filetransfer/util/FileChunk.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/openslx/filetransfer/util/FileChunk.java b/src/main/java/org/openslx/filetransfer/util/FileChunk.java index 36892fb..4b6ee74 100644 --- a/src/main/java/org/openslx/filetransfer/util/FileChunk.java +++ b/src/main/java/org/openslx/filetransfer/util/FileChunk.java @@ -16,6 +16,7 @@ public class FileChunk private int failCount = 0; protected byte[] sha1sum; protected ChunkStatus status = ChunkStatus.MISSING; + private boolean writtenToDisk = false; public FileChunk( long startOffset, long endOffset, byte[] sha1sum ) { @@ -32,7 +33,7 @@ public class FileChunk if ( this.sha1sum != null || sha1sum == null || sha1sum.length != SHA1_LENGTH ) return; this.sha1sum = sha1sum; - if ( this.status == ChunkStatus.COMPETE ) { + if ( this.status == ChunkStatus.COMPLETE ) { this.status = ChunkStatus.HASHING; } } @@ -69,9 +70,23 @@ public class FileChunk return status; } + /** + * Whether the chunk of data this chunk refers to has been written to + * disk and is assumed to be valid/up to date. + */ + public synchronized boolean isWrittenToDisk() + { + return writtenToDisk; + } + protected synchronized void setStatus( ChunkStatus status ) { if ( status != null ) { + if ( status == ChunkStatus.COMPLETE ) { + this.writtenToDisk = true; + } else if ( status == ChunkStatus.MISSING ) { + this.writtenToDisk = false; + } this.status = status; } } |