Don't merge.

This commit is contained in:
Paul Schneider 2021-05-14 01:41:52 +01:00
commit c83ff84370
6 changed files with 80 additions and 157 deletions

View file

@ -9,44 +9,39 @@ namespace nuget_cli
{
internal class PushCommand
{
private static readonly int MAXSENDLEN = 0xffff;
static internal async Task<PushReport> RunAsync(string pkg, string source, string apikey)
{
FileInfo fi = new FileInfo(pkg);
var report = new PushReport
{
PkgName = pkg
PkgName = fi.Name
};
FileInfo fi = new FileInfo(pkg);
if (!fi.Exists)
throw new Exception("Le fichier n'existe pas");
var fparams = new Dictionary<string, string> { };
{
report.StatusCode = "local";
report.Message = "Le fichier n'existe pas";
return report;
}
try
try
{
await report.UploadFilesToServer(new Uri(source), fi, apikey);
}
catch (WebException ex)
{
await Console.Error.WriteLineAsync(ex.Message);
report.StatusCode = ex.Status.ToString();
using (var respStream = ex.Response.GetResponseStream())
{
report.UploadFilesToServer(new Uri(source),
fparams, fi, "application/octet-stream",
apikey);
}
catch (WebException ex)
{
await Console.Error.WriteLineAsync(ex.Message);
report.StatusCode = ex.Status.ToString();
using (var respStream = ex.Response.GetResponseStream())
{
StreamReader sr = new StreamReader(respStream);
report.Message = sr.ReadToEnd();
}
}
catch (Exception ex)
{
await Console.Error.WriteLineAsync(ex.Message);
throw;
StreamReader sr = new StreamReader(respStream);
report.Message = sr.ReadToEnd();
}
}
catch (Exception ex)
{
await Console.Error.WriteLineAsync(ex.Message);
throw;
}
report.Executed = true;
return report;
}