fixes the push
This commit is contained in:
@ -5,6 +5,7 @@ using isnd.Attributes;
|
|||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
using isn.abst;
|
using isn.abst;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
@ -27,17 +28,18 @@ namespace isnd.Controllers
|
|||||||
return BadRequest("Package does´nt exist in the file system.");
|
return BadRequest("Package does´nt exist in the file system.");
|
||||||
var pkgVersionDirInfo = pkgDirInfo.GetDirectories().FirstOrDefault(
|
var pkgVersionDirInfo = pkgDirInfo.GetDirectories().FirstOrDefault(
|
||||||
s=>s.Name==version);
|
s=>s.Name==version);
|
||||||
|
if (pkgVersionDirInfo==null)
|
||||||
|
return BadRequest("Package does´nt exist in the specified version.");
|
||||||
|
|
||||||
var pkgNameSpec=$"{id}-{version}.{Constants.PacketFileExtension}";
|
var pkgNameSpec=$"{id}-{version}.{Constants.PacketFileExtension}";
|
||||||
|
|
||||||
if (pkgVersionDirInfo == null)
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
FileInfo pkgFileInfo = pkgVersionDirInfo.GetFiles()
|
FileInfo pkgFileInfo = pkgVersionDirInfo.GetFiles()
|
||||||
.FirstOrDefault(p=>string.Compare(p.Name,pkgNameSpec,
|
.FirstOrDefault(p=>string.Compare(p.Name,pkgNameSpec,
|
||||||
System.StringComparison.InvariantCultureIgnoreCase)==0);
|
System.StringComparison.InvariantCultureIgnoreCase)==0);
|
||||||
|
|
||||||
if (!pkgFileInfo.Exists)
|
if (pkgFileInfo==null || !pkgFileInfo.Exists)
|
||||||
{
|
{
|
||||||
|
logger.LogError($"Not found in {pkgVersionDirInfo.FullName} : {pkgNameSpec}");
|
||||||
return BadRequest("Package version does´nt exist in the file system.");
|
return BadRequest("Package version does´nt exist in the file system.");
|
||||||
}
|
}
|
||||||
return File(pkgFileInfo.OpenRead(), "application/zip; charset=binary");
|
return File(pkgFileInfo.OpenRead(), "application/zip; charset=binary");
|
||||||
|
@ -34,23 +34,28 @@ namespace isnd.Controllers
|
|||||||
logger.LogError("403 : no api-key");
|
logger.LogError("403 : no api-key");
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
|
bool foundPackage = false;
|
||||||
|
|
||||||
foreach (IFormFile file in Request.Form.Files)
|
foreach (IFormFile file in Request.Form.Files)
|
||||||
{
|
{
|
||||||
FileInfo inputFileInfo = new FileInfo(file.Name);
|
FileInfo inputFileInfo = new FileInfo(file.FileName);
|
||||||
switch (inputFileInfo.Extension)
|
switch (inputFileInfo.Extension)
|
||||||
{
|
{
|
||||||
case "nupkg":
|
case ".nupkg":
|
||||||
case "nupkgs":
|
case ".nupkgs":
|
||||||
var libVersion = await packageManager.PutPackageAsync(inputFileInfo.Extension, file.OpenReadStream(), dbApiKey.UserId);
|
var libVersion = await packageManager.PutPackageAsync(inputFileInfo.Extension, file.OpenReadStream(), dbApiKey.UserId);
|
||||||
logger.LogInformation($"new package : {libVersion.PackageId} {libVersion.NugetLink}");
|
logger.LogInformation($"new package : {libVersion.PackageId} {libVersion.NugetLink}");
|
||||||
|
foundPackage = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.LogInformation($"file extension is not supported : {inputFileInfo.Extension}");
|
logger.LogInformation($"file extension is not supported : {inputFileInfo.Extension}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return Ok();
|
if (foundPackage)
|
||||||
|
return Ok();
|
||||||
|
return BadRequest("no package");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -441,7 +441,7 @@ namespace isnd.Services
|
|||||||
string packageIdPath = Path.Combine(isndSettings.PackagesRootDir,
|
string packageIdPath = Path.Combine(isndSettings.PackagesRootDir,
|
||||||
pkgId);
|
pkgId);
|
||||||
pkgPath = Path.Combine(packageIdPath, nugetVersion.ToFullString());
|
pkgPath = Path.Combine(packageIdPath, nugetVersion.ToFullString());
|
||||||
string name = $"{pkgId}-{nugetVersion}." + fileExtension;
|
string name = $"{pkgId}-{nugetVersion}" + fileExtension;
|
||||||
fullPath = Path.Combine(pkgPath, name);
|
fullPath = Path.Combine(pkgPath, name);
|
||||||
|
|
||||||
var authors = xMetaElements.FirstOrDefault(x => x.Name.LocalName == "authors")?.Value;
|
var authors = xMetaElements.FirstOrDefault(x => x.Name.LocalName == "authors")?.Value;
|
||||||
|
BIN
test/data/packages/AsciiDocNet.1.0.0.nupkg
Normal file
BIN
test/data/packages/AsciiDocNet.1.0.0.nupkg
Normal file
Binary file not shown.
@ -3,4 +3,7 @@
|
|||||||
<packageSources>
|
<packageSources>
|
||||||
<add key="localhost" value="https://localhost:5001/v3/index.json" protocolVersion="3" />
|
<add key="localhost" value="https://localhost:5001/v3/index.json" protocolVersion="3" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
|
<disabledPackageSources>
|
||||||
|
<add key="localhost" value="true" />
|
||||||
|
</disabledPackageSources>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -183,7 +183,7 @@ namespace isnd.host.tests
|
|||||||
PackageUpdateResource pushRes = await repository.GetResourceAsync<PackageUpdateResource>();
|
PackageUpdateResource pushRes = await repository.GetResourceAsync<PackageUpdateResource>();
|
||||||
SymbolPackageUpdateResourceV3 symbolPackageResource = await repository.GetResourceAsync<SymbolPackageUpdateResourceV3>();
|
SymbolPackageUpdateResourceV3 symbolPackageResource = await repository.GetResourceAsync<SymbolPackageUpdateResourceV3>();
|
||||||
|
|
||||||
await pushRes.Push(new List<string>{ "../../../Yavsc.Abstract.1.0.8.nupkg" }, null,
|
await pushRes.Push(new List<string>{ "/home/paul/workspace/isn/test/data/packages/AsciiDocNet.1.0.0.nupkg" }, null,
|
||||||
5000, false, GetApiKey, GetSymbolsApiKey, false, false, symbolPackageResource, logger);
|
5000, false, GetApiKey, GetSymbolsApiKey, false, false, symbolPackageResource, logger);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user