}
if(origData == null) return null;
if(!mustCopy)
return new CacheFetchResult(new ClientMetadata(mime), origData, filtered);
Bucket newData = null;
try {
if(preferred != null) newData = preferred;
else newData = core.tempBucketFactory.makeBucket(origData.size());
BucketTools.copy(origData, newData);
if(origData.size() != newData.size()) {
Logger.normal(this, "Maybe it disappeared under us?");
newData.free();
newData = null;
return null;
}
return new CacheFetchResult(new ClientMetadata(mime), newData, filtered);
} catch (IOException e) {
// Maybe it was freed?
Logger.normal(this, "Unable to copy data: "+e, e);
return null;
}