public async Task<bool> MirrorAsync(string id, string version, CancellationToken token)
{
var publish = true;
if (!_overwriteExisting)
{
publish = !(await _destinationPackageDownloader.IsAvailableAsync(id, version, token));
}
if (publish)
{
publish = await _sourcePackageDownloader.ProcessAsync(
id,
version,
async streamResult =>
{
if (!streamResult.IsAvailable)
{
throw new InvalidOperationException($"The VSIX package '{id}' (version '{version}') is not available on the source.");
}
await _packagePusher.PushAsync(streamResult.Stream, token);
return true;
},
token);
}
return publish;
}
}