Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug workaround: Copy nupkg to stream before Azure upload #24

Merged
merged 1 commit into from
Mar 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/NuGet.V3Repository/V3Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task<Uri> AddPackage(Stream stream, IPackageMetadata packageMetadat
string id = nuspec.GetId();
string version = nuspec.GetVersion().ToNormalizedString();

// TODO: consider closing the steam after save to flat container is done
// TODO: consider closing the stream after save to flat container is done
var packageLocations = await AddToFlatContainer(stream, packageMetadata, id, version);

Tuple<Uri, IGraph> catalogItem = await AddToCatalog(v3PackageMetadata, id, version);
Expand All @@ -122,13 +122,19 @@ await RegistrationMaker.Process(
{
_logger.LogInformation($"Adding package: {id}, {version}");

stream.Position = 0;
var packageLocations =
await _dnxMaker.AddPackage(stream, packageMetadata.Nuspec.ToString(), id, version, CancellationToken.None);
// This is a workaround for this issue: https://github.com/Azure/azure-storage-net/issues/202
// When resolved, we can save directly from the stream
var data = new byte[stream.Length];
using (var ms = new MemoryStream(data, writable: true))
{
await stream.CopyToAsync(ms);
var packageLocations =
await _dnxMaker.AddPackage(ms, packageMetadata.Nuspec.ToString(), id, version, CancellationToken.None);

_logger.LogInformation($"Package {id}, {version} was added to flat container");
_logger.LogInformation($"Package {id}, {version} was added to flat container");

return packageLocations;
return packageLocations;
}
}

private async Task<Tuple<Uri, IGraph>> AddToCatalog(V3PackageMetadata packageMetadata, string id, string version)
Expand Down