if(returnType == ReturnType.DISK) {
dos.writeUTF(targetFile.toString());
}
dos.writeBoolean(binaryBlob);
DataOutputStream innerDOS =
new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory()));
try {
fctx.writeTo(innerDOS);
} finally {
innerDOS.close();
}
if(extensionCheck != null) {
dos.writeBoolean(true);
dos.writeUTF(extensionCheck);
} else {
dos.writeBoolean(false);
}
if(initialMetadata != null) {
dos.writeBoolean(true);
initialMetadata.storeTo(innerDOS);
} else {
dos.writeBoolean(false);
}
synchronized(this) {
if(finished) {
dos.writeBoolean(succeeded);
writeTransientProgressFields(dos);
if(succeeded) {
if(returnType == ReturnType.DIRECT) {
innerDOS =
new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory()));
try {
returnBucketDirect.storeTo(innerDOS);
} finally {
innerDOS.close();
}
}
} else {
innerDOS =
new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory()));
try {
getFailedMessage.writeTo(innerDOS);
} finally {
innerDOS.close();
}
}
return;
}
}
// Not finished, or was recently not finished.
// Don't hold lock while calling getter.
// If it's just finished we get a race and restart. That's okay.
innerDOS =
new DataOutputStream(checker.checksumWriterWithLength(dos, new ArrayBucketFactory()));
try {
if(getter.writeTrivialProgress(innerDOS)) {
writeTransientProgressFields(innerDOS);
}
} finally {