Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 233214 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java (-12 / +19 lines)
Lines 396-402 Link Here
396
		return artifactDescriptors.remove(descriptor);
396
		return artifactDescriptors.remove(descriptor);
397
	}
397
	}
398
398
399
	protected IStatus downloadArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
399
	private IStatus downloadArtifact(IArtifactDescriptor descriptor, String mirrorLocation, OutputStream destination, IProgressMonitor monitor) {
400
		if (isFolderBased(descriptor)) {
400
		if (isFolderBased(descriptor)) {
401
			File artifactFolder = getArtifactFile(descriptor);
401
			File artifactFolder = getArtifactFile(descriptor);
402
			// TODO: optimize and ensure manifest is written first
402
			// TODO: optimize and ensure manifest is written first
Lines 415-423 Link Here
415
			return Status.OK_STATUS;
415
			return Status.OK_STATUS;
416
		}
416
		}
417
417
418
		//download from the best available mirror
419
		String baseLocation = getLocation(descriptor);
420
		String mirrorLocation = getMirror(baseLocation);
421
		IStatus result = getTransport().download(mirrorLocation, destination, monitor);
418
		IStatus result = getTransport().download(mirrorLocation, destination, monitor);
422
		if (mirrors != null)
419
		if (mirrors != null)
423
			mirrors.reportResult(mirrorLocation, result);
420
			mirrors.reportResult(mirrorLocation, result);
Lines 434-439 Link Here
434
		return result;
431
		return result;
435
	}
432
	}
436
433
434
	protected IStatus downloadArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
435
		String baseLocation = getLocation(descriptor);
436
		String mirrorLocation = getMirror(baseLocation);
437
		IStatus status = downloadArtifact(descriptor, mirrorLocation, destination, monitor);
438
		IStatus result = reportStatus(descriptor, destination, status);
439
		// if the original download went reasonably but the reportStatus found some issues
440
		// (e..g, in the processing steps/validators) then mark the mirror as bad and return
441
		// a retry code (assuming we have more mirrors)
442
		if ((status.isOK() || status.matches(IStatus.OK | IStatus.INFO | IStatus.WARNING)) && result.getSeverity() == IStatus.ERROR) {
443
			mirrors.reportResult(mirrorLocation, result);
444
			if (mirrors != null && mirrors.hasValidMirror())
445
				return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {result}, "Retry another mirror", null); //$NON-NLS-1$
446
		}
447
		// if the original status was a retry, don't lose that.
448
		return status.getCode() == CODE_RETRY ? status : result;
449
	}
450
437
	/**
451
	/**
438
	 * Returns an equivalent mirror location for the given artifact location.
452
	 * Returns an equivalent mirror location for the given artifact location.
439
	 * @param baseLocation The location of the artifact in this repository
453
	 * @param baseLocation The location of the artifact in this repository
Lines 468-481 Link Here
468
		if (!status.isOK() && status.getSeverity() != IStatus.INFO)
482
		if (!status.isOK() && status.getSeverity() != IStatus.INFO)
469
			return status;
483
			return status;
470
484
471
		status = downloadArtifact(descriptor, destination, monitor);
485
		return downloadArtifact(descriptor, destination, monitor);
472
		IStatus result = reportStatus(descriptor, destination, status);
473
		// if the original status was RETRY then ensure that we return that status.  It is
474
		// however important to call reportStatus() either way as it updates information
475
		// in addition to collecting status.
476
		// TODO we should remove this when there is more time for testing.
477
		return status.getCode() == CODE_RETRY ? status : result;
478
479
	}
486
	}
480
487
481
	public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
488
	public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {

Return to bug 233214