ignore code 1
This commit is contained in:
@ -3,9 +3,15 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace nuget_cli
|
||||
{
|
||||
public class nugetdresp {
|
||||
public int ecode {get; set; }
|
||||
public string message {get; set; }
|
||||
public string id { get; set; }
|
||||
}
|
||||
public class UploadFilesToServerUsingWebRequest
|
||||
{
|
||||
|
||||
@ -83,10 +89,17 @@ namespace nuget_cli
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
|
||||
var res = JsonConvert.DeserializeObject<nugetdresp>(json);
|
||||
report.AlreadyPresent = res.ecode == 1;
|
||||
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
// ecode == 1 => package already present server side.
|
||||
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");
|
||||
}
|
||||
|
@ -120,7 +120,8 @@ namespace nuget_host.Controllers
|
||||
var destdir = new DirectoryInfo(dest.DirectoryName);
|
||||
if (dest.Exists)
|
||||
{
|
||||
ViewData["error"] = "existant";
|
||||
ViewData["msg"] = "existant";
|
||||
ViewData["ecode"] = 1;
|
||||
logger.LogWarning("400 : existant");
|
||||
return BadRequest(ViewData);
|
||||
}
|
||||
@ -180,7 +181,7 @@ namespace nuget_host.Controllers
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
ViewData["warn"] = "no id";
|
||||
ViewData["msg"] = "no id";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user