nugetd
This commit is contained in:
parent
be30ef3c25
commit
1266dd54db
5 changed files with 137 additions and 13 deletions
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue