mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18119: Fixing feed background checks
Work Item: 18119 --HG-- branch : 1.x
This commit is contained in:
@@ -7,6 +7,7 @@ using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Packaging.Models;
|
||||
using Orchard.Packaging.Services;
|
||||
using Orchard.Packaging.ViewModels;
|
||||
@@ -44,6 +45,7 @@ namespace Orchard.Packaging.Controllers {
|
||||
|
||||
Services = services;
|
||||
Shape = shapeFactory;
|
||||
PackageUpdateService = packageUpdateService;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
@@ -53,6 +55,7 @@ namespace Orchard.Packaging.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
public dynamic Shape { get; set; }
|
||||
public IPackageUpdateService PackageUpdateService { get; set; }
|
||||
|
||||
public ActionResult ThemesUpdates(int? reportId, PagerParameters pagerParameters) {
|
||||
return PackageUpdate("ThemesUpdates", DefaultExtensionTypes.Theme, reportId, pagerParameters);
|
||||
@@ -62,6 +65,14 @@ namespace Orchard.Packaging.Controllers {
|
||||
return PackageUpdate("ModulesUpdates", DefaultExtensionTypes.Module, reportId, pagerParameters);
|
||||
}
|
||||
|
||||
public ActionResult ReloadUpdates(string returnUrl) {
|
||||
_packageUpdateService.TriggerRefresh();
|
||||
|
||||
Services.Notifier.Warning(T("The feed has been notified for update. It might take a few minutes before the updates are displayed."));
|
||||
|
||||
return this.RedirectLocal(returnUrl);
|
||||
}
|
||||
|
||||
private ActionResult PackageUpdate(string view, string extensionType, int? reportId, PagerParameters pagerParameters) {
|
||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
@@ -61,24 +61,28 @@ namespace Orchard.Packaging.Services {
|
||||
}
|
||||
|
||||
private PackagesStatusResult GetPackages(PackagingSource packagingSource) {
|
||||
return _cacheManager.Get(packagingSource.FeedUrl, ctx => {
|
||||
// Refresh every minute or when signal was triggered
|
||||
ctx.Monitor(_clock.When(TimeSpan.FromMinutes(5)));
|
||||
ctx.Monitor(_signals.When("PackageUpdateService"));
|
||||
// Refresh every time 5 minutes AND signal was triggered (not or, otherwise the request would go every 5 minutes, whatever)
|
||||
// Signal is triggered when the Modules page is displayed
|
||||
return _cacheManager.Get(packagingSource.FeedUrl, ctx1 => {
|
||||
ctx1.Monitor(_clock.When(TimeSpan.FromMinutes(5)));
|
||||
|
||||
// We cache exception because we are calling on a network feed, and failure may
|
||||
// take quite some time.
|
||||
var result = new PackagesStatusResult {
|
||||
Entries = new List<UpdatePackageEntry>(),
|
||||
Errors = new List<Exception>()
|
||||
};
|
||||
try {
|
||||
result.Entries = GetPackagesWorker(packagingSource);
|
||||
}
|
||||
catch (Exception e) {
|
||||
result.Errors = new[] { e };
|
||||
}
|
||||
return result;
|
||||
return _cacheManager.Get(packagingSource.FeedUrl, ctx2 => {
|
||||
ctx2.Monitor(_signals.When("PackageUpdateService"));
|
||||
|
||||
// We cache exception because we are calling on a network feed, and failure may
|
||||
// take quite some time.
|
||||
var result = new PackagesStatusResult {
|
||||
Entries = new List<UpdatePackageEntry>(),
|
||||
Errors = new List<Exception>()
|
||||
};
|
||||
try {
|
||||
result.Entries = GetPackagesWorker(packagingSource);
|
||||
}
|
||||
catch (Exception e) {
|
||||
result.Errors = new[] { e };
|
||||
}
|
||||
return result;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -81,4 +81,10 @@
|
||||
display: inline;
|
||||
height: auto;
|
||||
padding-top: 0;
|
||||
}
|
||||
.update-actions {
|
||||
float: right;
|
||||
display: inline;
|
||||
height: auto;
|
||||
padding-top: 0;
|
||||
}
|
@@ -25,6 +25,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
<fieldset class="update-actions">
|
||||
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" >@T("Refresh")</a>
|
||||
</fieldset>
|
||||
|
||||
@if (Model.Entries.Count() <= 0) {
|
||||
<p>@T("No module updates available.").ToString()</p>
|
||||
} else {
|
||||
|
@@ -14,7 +14,7 @@
|
||||
TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
|
||||
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,
|
||||
Orchard.Scripting,Orchard.Scripting.Lightweight,
|
||||
PackagingServices,Orchard.Packaging,Gallery.Updates,Orchard.Warmup,
|
||||
PackagingServices,Orchard.Packaging,Orchard.Warmup,
|
||||
TheThemeMachine" />
|
||||
|
||||
<Metadata>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
</Recipe>
|
||||
|
||||
<Feature disable="Feeds, Containers"
|
||||
enable="Orchard.jQuery,Gallery.Updates" />
|
||||
enable="Orchard.jQuery" />
|
||||
|
||||
<Metadata>
|
||||
<Types>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
Orchard.Lists,TinyMce,Orchard.Media,Orchard.MediaPicker,Orchard.PublishLater,
|
||||
Orchard.jQuery,Orchard.Widgets,Orchard.Widgets.PageLayerHinting,Orchard.ContentTypes,
|
||||
Orchard.Scripting,Orchard.Scripting.Lightweight,
|
||||
PackagingServices,Orchard.Packaging,Gallery.Updates,Orchard.Warmup,
|
||||
PackagingServices,Orchard.Packaging,Orchard.Warmup,
|
||||
TheThemeMachine" />
|
||||
|
||||
<Metadata>
|
||||
|
Reference in New Issue
Block a user