ignore code 1

broken/ef
Paul Schneider 3 years ago
parent 3fa1241ea2
commit 981f3209e0
2 changed files with 17 additions and 3 deletions

@ -3,9 +3,15 @@ using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
namespace nuget_cli namespace nuget_cli
{ {
public class nugetdresp {
public int ecode {get; set; }
public string message {get; set; }
public string id { get; set; }
}
public class UploadFilesToServerUsingWebRequest public class UploadFilesToServerUsingWebRequest
{ {
@ -83,10 +89,17 @@ namespace nuget_cli
{ {
String json = re.ReadToEnd(); String json = re.ReadToEnd();
report.Message = json; report.Message = json;
var res = JsonConvert.DeserializeObject<nugetdresp>(json);
report.AlreadyPresent = res.ecode == 1;
var hrep = resp as HttpWebResponse; var hrep = resp as HttpWebResponse;
report.StatusCode = hrep.StatusCode.ToString(); report.StatusCode = hrep.StatusCode.ToString();
// ecode == 1 => package already present server side.
report.OK = hrep.StatusCode == report.OK = hrep.StatusCode ==
HttpStatusCode.Accepted || hrep.StatusCode == HttpStatusCode.OK; HttpStatusCode.Accepted
|| hrep.StatusCode == HttpStatusCode.OK
|| res.ecode == 1;
} }
else throw new Exception("Invalid server response type"); else throw new Exception("Invalid server response type");
} }

@ -120,7 +120,8 @@ namespace nuget_host.Controllers
var destdir = new DirectoryInfo(dest.DirectoryName); var destdir = new DirectoryInfo(dest.DirectoryName);
if (dest.Exists) if (dest.Exists)
{ {
ViewData["error"] = "existant"; ViewData["msg"] = "existant";
ViewData["ecode"] = 1;
logger.LogWarning("400 : existant"); logger.LogWarning("400 : existant");
return BadRequest(ViewData); return BadRequest(ViewData);
} }
@ -180,7 +181,7 @@ namespace nuget_host.Controllers
{ {
if (string.IsNullOrEmpty(id)) if (string.IsNullOrEmpty(id))
{ {
ViewData["warn"] = "no id"; ViewData["msg"] = "no id";
} }
else else
{ {

Loading…