int infosFetchedThisTask = 0;
while (!toImport.isEmpty() && infosFetchedThisTask < MAX_FETCHES_PER_TASK) {
RemoteAttachmentInfo info = toImport.removeFirst();
AttachmentId localId = fetchAttachment(instance, info);
log.info("Local id: " + localId);
ImportedAttachmentInfo imported = new ImportedAttachmentInfoGsonImpl();
imported.setRemoteInfo(info);
if (localId != null) {
imported.setLocalId(localId.getId());
}
infosFetchedThisTask++;
task.addImported(imported);
}
if (toImport.isEmpty()) {