NuGet Gallery搜索索引应在何时更新?
我最近根据上的说明安装了一个本地NuGet Gallery 当我通过UI上传包时,它似乎工作正常,但使用命令行推送的包不会显示在搜索结果中。在软件包窗口中显示“搜索索引上次更新是在55分钟前”。这与我上次发布该网站的时间一致。什么决定搜索索引何时运行?快速查看代码使其看起来像是在添加/删除包时应该发生的,但它似乎没有这样做NuGet Gallery搜索索引应在何时更新?,nuget,nuget-server,nugetgallery,Nuget,Nuget Server,Nugetgallery,我最近根据上的说明安装了一个本地NuGet Gallery 当我通过UI上传包时,它似乎工作正常,但使用命令行推送的包不会显示在搜索结果中。在软件包窗口中显示“搜索索引上次更新是在55分钟前”。这与我上次发布该网站的时间一致。什么决定搜索索引何时运行?快速查看代码使其看起来像是在添加/删除包时应该发生的,但它似乎没有这样做 如何增加索引频率?在NuGetGallery项目中,转到/Controllers/ApiController中的CreatePackageInternal方法,并在retur
如何增加索引频率?在NuGetGallery项目中,转到
/Controllers/ApiController
中的CreatePackageInternal
方法,并在return
语句之前调用此行
IndexingService.UpdateIndex(true);
您的代码必须是这样的
private async Task<ActionResult> CreatePackageInternal()
{
// Get the user
var user = GetCurrentUser();
using (var packageToPush = ReadPackageFromRequest())
{
if (packageToPush.Metadata.MinClientVersion > typeof(Manifest).Assembly.GetName().Version)
{
return new HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest, String.Format(
CultureInfo.CurrentCulture,
Strings.UploadPackage_MinClientVersionOutOfRange,
packageToPush.Metadata.MinClientVersion));
}
// Ensure that the user can push packages for this partialId.
var packageRegistration = PackageService.FindPackageRegistrationById(packageToPush.Metadata.Id);
if (packageRegistration != null)
{
if (!packageRegistration.IsOwner(user))
{
return new HttpStatusCodeWithBodyResult(HttpStatusCode.Forbidden, Strings.ApiKeyNotAuthorized);
}
// Check if a particular Id-Version combination already exists. We eventually need to remove this check.
string normalizedVersion = packageToPush.Metadata.Version.ToNormalizedString();
bool packageExists =
packageRegistration.Packages.Any(
p => String.Equals(
p.NormalizedVersion,
normalizedVersion,
StringComparison.OrdinalIgnoreCase));
if (packageExists)
{
return new HttpStatusCodeWithBodyResult(
HttpStatusCode.Conflict,
String.Format(CultureInfo.CurrentCulture, Strings.PackageExistsAndCannotBeModified,
packageToPush.Metadata.Id, packageToPush.Metadata.Version.ToNormalizedStringSafe()));
}
}
var package = PackageService.CreatePackage(packageToPush, user, commitChanges: false);
AutoCuratePackage.Execute(package, packageToPush, commitChanges: false);
EntitiesContext.SaveChanges();
using (Stream uploadStream = packageToPush.GetStream())
{
await PackageFileService.SavePackageFileAsync(package, uploadStream);
}
}
IndexingService.UpdateIndex(true);
return new HttpStatusCodeResult(HttpStatusCode.Created);
}
private异步任务CreatePackageInternal()
{
//获取用户
var user=GetCurrentUser();
使用(var packageToPush=ReadPackageFromRequest())
{
if(packageToPush.Metadata.MinClientVersion>typeof(Manifest.Assembly.GetName().Version)
{
返回新的HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest,String.Format(
CultureInfo.CurrentCulture,
Strings.UploadPackage\u minClientVersionAutoFrange,
packagetOpsh.Metadata.MinClientVersion);
}
//确保用户可以推送此partialId的包。
var packagerregistration=PackageService.FindPackageRegistrationById(packagetopsh.Metadata.Id);
if(packageRegistration!=null)
{
如果(!packageRegistration.IsOwner(用户))
{
返回新的HttpStatusCodeWithBodyResult(HttpStatusCode.Forbidded,Strings.ApikeNotAuthorized);
}
//检查特定Id版本组合是否已存在。我们最终需要删除此检查。
字符串normalizedVersion=packagetOpsh.Metadata.Version.ToNormalizedString();
布尔包装主义者=
packageRegistration.Packages.Any(
p=>String.Equals(
p、 标准化版本,
标准化版本,
StringComparison(Ordinalingorecase));
如果(packageExists)
{
返回新的HttpStatusCodeWithBodyResult(
HttpStatusCode.Conflict,
格式(CultureInfo.CurrentCulture、Strings.PackageExists和CannotbeModified,
packagetopsh.Metadata.Id,packagetopsh.Metadata.Version.ToNormalizedStringSafe());
}
}
var package=PackageService.CreatePackage(packagetopsh,user,commitChanges:false);
AutoCuratePackage.Execute(package、packagetopsh、commitChanges:false);
EntitiesContext.SaveChanges();
使用(Stream uploadStream=packagetopsh.GetStream())
{
wait PackageFileService.SavePackageFileAsync(package,uploadStream);
}
}
IndexingService.UpdateIndex(true);
返回新的HttpStatusCodeResult(HttpStatusCode.Created);
}