@Override
public boolean snoopMetadata(Metadata meta, ClientContext context) {
String mimeType = meta.getMIMEType();
- return (mimeType == null) || backgroundFetchCallback.cancelForMimeType(uri, mimeType);
+ boolean cancel = (mimeType == null) || backgroundFetchCallback.shouldCancel(uri, mimeType, meta.dataLength());
+ if (cancel) {
+ backgroundFetchCallback.failed(uri);
+ }
+ return cancel;
}
};
FetchContext fetchContext = client.getFetchContext();
try {
- ClientGetter clientGetter = client.fetch(uri, 1048576, callback, fetchContext, RequestStarter.INTERACTIVE_PRIORITY_CLASS);
+ ClientGetter clientGetter = client.fetch(uri, 2097152, callback, fetchContext, RequestStarter.INTERACTIVE_PRIORITY_CLASS);
clientGetter.setMetaSnoop(snoop);
clientGetter.restart(uri, fetchContext.filterData, node.clientCore.clientContext);
} catch (FetchException fe) {
}
public interface BackgroundFetchCallback {
- boolean cancelForMimeType(@Nonnull FreenetURI uri, @Nonnull String mimeType);
+ boolean shouldCancel(@Nonnull FreenetURI uri, @Nonnull String mimeType, long size);
void loaded(@Nonnull FreenetURI uri, @Nonnull String mimeType, @Nonnull byte[] data);
void failed(@Nonnull FreenetURI uri);
}