Compare commits

3 Commits

Author SHA1 Message Date
cbe5614794 fixes the push 2025-07-14 17:12:15 +01:00
f03c56fead Merge branch 'main' of gitea.pschneider.fr:paul/isn 2025-07-08 17:47:24 +01:00
26e253a3ab get prereleases from restoration by default
Fixes the .nupkgs pushes
2025-07-08 17:46:11 +01:00
10 changed files with 42 additions and 21 deletions

View File

@ -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,14 +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}";
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");

View File

@ -12,7 +12,7 @@ namespace isnd.Controllers
public IActionResult GetVersions( public IActionResult GetVersions(
string id, string id,
string version, string version,
bool prerelease = false, bool prerelease = true,
string packageType = null, string packageType = null,
int skip = 0, int skip = 0,
int take = 50) int take = 50)

View File

@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
using isnd.Entities; using isnd.Entities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using isn.abst; using isn.abst;
using System.IO;
namespace isnd.Controllers namespace isnd.Controllers
{ {
@ -33,12 +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)
{ {
var version = await packageManager.PutPackageAsync(file.OpenReadStream(), dbApiKey.UserId); FileInfo inputFileInfo = new FileInfo(file.FileName);
logger.LogInformation($"new package : {version.PackageId} {version.NugetLink}"); switch (inputFileInfo.Extension)
{
case ".nupkg":
case ".nupkgs":
var libVersion = await packageManager.PutPackageAsync(inputFileInfo.Extension, file.OpenReadStream(), dbApiKey.UserId);
logger.LogInformation($"new package : {libVersion.PackageId} {libVersion.NugetLink}");
foundPackage = true;
break;
default:
logger.LogInformation($"file extension is not supported : {inputFileInfo.Extension}");
break;
}
} }
return Ok(); if (foundPackage)
return Ok();
return BadRequest("no package");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -30,7 +30,7 @@ namespace isnd.Interfaces
Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query); Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query);
Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId); Task<PackageVersion> PutPackageAsync(string fileExtension, Stream packageStream, string ownerId);
} }
} }

View File

@ -396,7 +396,7 @@ namespace isnd.Services
return new PackageSearchResult(packages, apiBase, count); return new PackageSearchResult(packages, apiBase, count);
} }
public async Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId) public async Task<PackageVersion> PutPackageAsync(string fileExtension, Stream packageStream, string ownerId)
{ {
PackageVersion version = null; PackageVersion version = null;
using (packageStream) using (packageStream)
@ -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}." + Constants.PacketFileExtension; 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;

View File

@ -52,7 +52,10 @@ namespace isnd
.Configure<AdminStartupList>(adminStartupListConf) .Configure<AdminStartupList>(adminStartupListConf)
.Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate") .Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate")
.AddDbContext<ApplicationDbContext>(options => .AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))) options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))
.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning))
.EnableDetailedErrors()
)
.AddIdentity<ApplicationUser, IdentityRole>() .AddIdentity<ApplicationUser, IdentityRole>()
.AddRoles<IdentityRole>() .AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>( .AddEntityFrameworkStores<ApplicationDbContext>(
@ -96,7 +99,7 @@ namespace isnd
s.SerializerSettings.ReferenceResolverProvider = () => new NSJWebApiReferenceResolver(); s.SerializerSettings.ReferenceResolverProvider = () => new NSJWebApiReferenceResolver();
}) })
.AddXmlSerializerFormatters(); .AddXmlSerializerFormatters();
#if SWAGGER #if SWAGGER
services.AddSwaggerGen(options => services.AddSwaggerGen(options =>
{ {
options.SwaggerDoc("v1", new OpenApiInfo options.SwaggerDoc("v1", new OpenApiInfo
@ -119,7 +122,7 @@ namespace isnd
var xmlFilename = $"{typeof(Startup).Assembly.GetName().Name}.xml"; var xmlFilename = $"{typeof(Startup).Assembly.GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
}); });
#endif #endif
} }
@ -134,10 +137,10 @@ namespace isnd
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint(); app.UseMigrationsEndPoint();
#if SWAGGER #if SWAGGER
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(); app.UseSwaggerUI();
#endif #endif
} }
else else
{ {

Binary file not shown.

View File

@ -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>

View File

@ -11,11 +11,4 @@
<Version>1.0.7</Version> <Version>1.0.7</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<PackageReference Include="isn.abst" Version="1.0.24" />
</ItemGroup>
</Project> </Project>

View File

@ -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);
} }