nugetd
This commit is contained in:
@ -51,5 +51,9 @@ namespace nuget_host.Controllers
|
||||
return Ok(ViewData);
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,19 +87,18 @@ namespace nuget_host.Controllers
|
||||
string pkgpath = Path.Combine(pkgidpath, version.ToFullString());
|
||||
string name = $"{pkgid}-{version}.nupkg";
|
||||
string fullpath = Path.Combine(pkgpath, name);
|
||||
Package package;
|
||||
|
||||
var destpkgiddir = new DirectoryInfo(pkgidpath);
|
||||
if (destpkgiddir.Exists)
|
||||
Package package = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||
if (package != null)
|
||||
{
|
||||
package = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||
if (package != null) if (package.OwnerId != apikey.UserId)
|
||||
{
|
||||
return new ForbidResult();
|
||||
}
|
||||
if (package.OwnerId != apikey.UserId)
|
||||
{
|
||||
return new ForbidResult();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
destpkgiddir.Create();
|
||||
package = new Package
|
||||
{
|
||||
Id = pkgid,
|
||||
@ -108,6 +107,7 @@ namespace nuget_host.Controllers
|
||||
};
|
||||
dbContext.Packages.Add(package);
|
||||
}
|
||||
if (!destpkgiddir.Exists) destpkgiddir.Create();
|
||||
|
||||
var source = new FileInfo(initpath);
|
||||
var dest = new FileInfo(fullpath);
|
||||
@ -137,6 +137,7 @@ namespace nuget_host.Controllers
|
||||
await dbContext.SaveChangesAsync();
|
||||
logger.LogInformation($"new package : {entry.Name}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,7 +147,9 @@ namespace nuget_host.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ObjectResult(new { ViewData, ex.Message, ex.StackTrace })
|
||||
logger.LogError(ex.Message);
|
||||
logger.LogError("Stack Trace: "+ ex.StackTrace);
|
||||
return new ObjectResult(new { ViewData, ex.Message})
|
||||
{ StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
|
@ -69,20 +69,22 @@ namespace nuget_host
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// app.UseExceptionHandler("/Home/Error");
|
||||
app.UseDeveloperExceptionPage();
|
||||
dbContext.Database.Migrate();
|
||||
}
|
||||
|
||||
app.UseStatusCodePages();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
template: "{controller=PackageVersion}/{action=Index}/{PackageId?}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
4
src/nuget-host/Views/Home/Error.cshtml
Normal file
4
src/nuget-host/Views/Home/Error.cshtml
Normal file
@ -0,0 +1,4 @@
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
Reference in New Issue
Block a user