mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Including Renaud's fixes to package updates
--HG-- branch : 1.x
This commit is contained in:
@@ -67,7 +67,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
|
|
||||||
public ActionResult ReloadUpdates(string returnUrl) {
|
public ActionResult ReloadUpdates(string returnUrl) {
|
||||||
_packageUpdateService.TriggerRefresh();
|
_packageUpdateService.TriggerRefresh();
|
||||||
|
_backgroundPackageUpdateStatus.Value = null;
|
||||||
|
|
||||||
Services.Notifier.Warning(T("The feed has been notified for update. It might take a few minutes before the updates are displayed."));
|
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);
|
return this.RedirectLocal(returnUrl);
|
||||||
@@ -97,8 +98,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
|
|
||||||
IEnumerable<UpdatePackageEntry> updatedPackages = _backgroundPackageUpdateStatus.Value.Entries
|
IEnumerable<UpdatePackageEntry> updatedPackages = _backgroundPackageUpdateStatus.Value.Entries
|
||||||
.Where(updatePackageEntry =>
|
.Where(updatePackageEntry =>
|
||||||
updatePackageEntry.ExtensionsDescriptor.ExtensionType.Equals(extensionType) &&
|
updatePackageEntry.ExtensionsDescriptor.ExtensionType.Equals(extensionType) &&
|
||||||
updatePackageEntry.NewVersionToInstall != null);
|
updatePackageEntry.NewVersionToInstall != null)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
int totalItemCount = updatedPackages.Count();
|
int totalItemCount = updatedPackages.Count();
|
||||||
|
|
||||||
@@ -107,6 +109,7 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return View(view, new PackagingListViewModel {
|
return View(view, new PackagingListViewModel {
|
||||||
|
LastUpdateCheckUtc = _backgroundPackageUpdateStatus.Value.DateTimeUtc,
|
||||||
Entries = updatedPackages,
|
Entries = updatedPackages,
|
||||||
Pager = Shape.Pager(pager).TotalItemCount(totalItemCount)
|
Pager = Shape.Pager(pager).TotalItemCount(totalItemCount)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Orchard.Environment.Extensions.Models;
|
|||||||
|
|
||||||
namespace Orchard.Packaging.Models {
|
namespace Orchard.Packaging.Models {
|
||||||
public class PackagesStatusResult {
|
public class PackagesStatusResult {
|
||||||
|
public DateTime DateTimeUtc { get; set; }
|
||||||
public IEnumerable<UpdatePackageEntry> Entries { get; set; }
|
public IEnumerable<UpdatePackageEntry> Entries { get; set; }
|
||||||
public IEnumerable<Exception> Errors { get; set; }
|
public IEnumerable<Exception> Errors { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
|
|
||||||
foreach (var source in sources) {
|
foreach (var source in sources) {
|
||||||
var sourceResult = GetPackages(source);
|
var sourceResult = GetPackages(source);
|
||||||
|
result.DateTimeUtc = sourceResult.DateTimeUtc;
|
||||||
result.Entries = result.Entries.Concat(sourceResult.Entries);
|
result.Entries = result.Entries.Concat(sourceResult.Entries);
|
||||||
result.Errors = result.Errors.Concat(sourceResult.Errors);
|
result.Errors = result.Errors.Concat(sourceResult.Errors);
|
||||||
}
|
}
|
||||||
@@ -61,28 +62,25 @@ namespace Orchard.Packaging.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PackagesStatusResult GetPackages(PackagingSource packagingSource) {
|
private PackagesStatusResult GetPackages(PackagingSource packagingSource) {
|
||||||
// Refresh every time 5 minutes AND signal was triggered (not or, otherwise the request would go every 5 minutes, whatever)
|
// Refresh every 23 hours or when signal was triggered
|
||||||
// Signal is triggered when the Modules page is displayed
|
return _cacheManager.Get(packagingSource.FeedUrl, ctx => {
|
||||||
return _cacheManager.Get(packagingSource.FeedUrl, ctx1 => {
|
ctx.Monitor(_clock.When(TimeSpan.FromMinutes(60 * 23)));
|
||||||
ctx1.Monitor(_clock.When(TimeSpan.FromMinutes(5)));
|
ctx.Monitor(_signals.When("PackageUpdateService"));
|
||||||
|
|
||||||
return _cacheManager.Get(packagingSource.FeedUrl, ctx2 => {
|
// We cache exception because we are calling on a network feed, and failure may
|
||||||
ctx2.Monitor(_signals.When("PackageUpdateService"));
|
// take quite some time.
|
||||||
|
var result = new PackagesStatusResult {
|
||||||
// We cache exception because we are calling on a network feed, and failure may
|
DateTimeUtc = _clock.UtcNow,
|
||||||
// take quite some time.
|
Entries = new List<UpdatePackageEntry>(),
|
||||||
var result = new PackagesStatusResult {
|
Errors = new List<Exception>()
|
||||||
Entries = new List<UpdatePackageEntry>(),
|
};
|
||||||
Errors = new List<Exception>()
|
try {
|
||||||
};
|
result.Entries = GetPackagesWorker(packagingSource);
|
||||||
try {
|
}
|
||||||
result.Entries = GetPackagesWorker(packagingSource);
|
catch (Exception e) {
|
||||||
}
|
result.Errors = new[] { e };
|
||||||
catch (Exception e) {
|
}
|
||||||
result.Errors = new[] { e };
|
return result;
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
@@ -43,7 +44,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
/// <param name="feedUrl">The feed url.</param>
|
/// <param name="feedUrl">The feed url.</param>
|
||||||
/// <returns>The feed identifier.</returns>
|
/// <returns>The feed identifier.</returns>
|
||||||
public int AddSource(string feedTitle, string feedUrl) {
|
public int AddSource(string feedTitle, string feedUrl) {
|
||||||
PackagingSource packagingSource = new PackagingSource { FeedTitle = feedTitle, FeedUrl = feedUrl };
|
var packagingSource = new PackagingSource { FeedTitle = feedTitle, FeedUrl = feedUrl };
|
||||||
|
|
||||||
_packagingSourceRecordRepository.Create(packagingSource);
|
_packagingSourceRecordRepository.Create(packagingSource);
|
||||||
|
|
||||||
@@ -70,20 +71,29 @@ namespace Orchard.Packaging.Services {
|
|||||||
/// <returns>The list of extensions.</returns>
|
/// <returns>The list of extensions.</returns>
|
||||||
public IEnumerable<PackagingEntry> GetExtensionList(bool includeScreenshots, PackagingSource packagingSource = null, Func<IQueryable<PublishedPackage>, IQueryable<PublishedPackage>> query = null) {
|
public IEnumerable<PackagingEntry> GetExtensionList(bool includeScreenshots, PackagingSource packagingSource = null, Func<IQueryable<PublishedPackage>, IQueryable<PublishedPackage>> query = null) {
|
||||||
return (packagingSource == null ? GetSources() : new[] {packagingSource})
|
return (packagingSource == null ? GetSources() : new[] {packagingSource})
|
||||||
.SelectMany(
|
.SelectMany(source => GetExtensionListFromSource(includeScreenshots, packagingSource, query, source));
|
||||||
source => {
|
}
|
||||||
var galleryFeedContext = new GalleryFeedContext(new Uri(source.FeedUrl)) { IgnoreMissingProperties = true };
|
|
||||||
IQueryable<PublishedPackage> packages = includeScreenshots
|
|
||||||
? galleryFeedContext.Packages.Expand("Screenshots")
|
|
||||||
: galleryFeedContext.Packages;
|
|
||||||
|
|
||||||
if (query != null) {
|
|
||||||
packages = query(packages);
|
|
||||||
}
|
|
||||||
|
|
||||||
return packages.ToList().Select(p => CreatePackageEntry(p, packagingSource, galleryFeedContext.GetReadStreamUri(p)));
|
private static IEnumerable<PackagingEntry> GetExtensionListFromSource(bool includeScreenshots, PackagingSource packagingSource, Func<IQueryable<PublishedPackage>, IQueryable<PublishedPackage>> query, PackagingSource source) {
|
||||||
}
|
var galleryFeedContext = new GalleryFeedContext(new Uri(source.FeedUrl)) { IgnoreMissingProperties = true };
|
||||||
);
|
|
||||||
|
// Setup compression
|
||||||
|
galleryFeedContext.SendingRequest += (o, e) => {
|
||||||
|
if (e.Request is HttpWebRequest) {
|
||||||
|
(e.Request as HttpWebRequest).AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Include screenshots if needed
|
||||||
|
IQueryable<PublishedPackage> packages = includeScreenshots
|
||||||
|
? galleryFeedContext.Packages.Expand("Screenshots")
|
||||||
|
: galleryFeedContext.Packages;
|
||||||
|
|
||||||
|
if (query != null) {
|
||||||
|
packages = query(packages);
|
||||||
|
}
|
||||||
|
|
||||||
|
return packages.ToList().Select(p => CreatePackageEntry(p, packagingSource, galleryFeedContext.GetReadStreamUri(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -110,7 +120,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static PackagingEntry CreatePackageEntry(PublishedPackage package, PackagingSource source, Uri downloadUri) {
|
private static PackagingEntry CreatePackageEntry(PublishedPackage package, PackagingSource source, Uri downloadUri) {
|
||||||
Uri baseUri = new Uri(string.Format("{0}://{1}:{2}/",
|
var baseUri = new Uri(string.Format("{0}://{1}:{2}/",
|
||||||
downloadUri.Scheme,
|
downloadUri.Scheme,
|
||||||
downloadUri.Host,
|
downloadUri.Host,
|
||||||
downloadUri.Port));
|
downloadUri.Port));
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Orchard.Packaging.Models;
|
using Orchard.Packaging.Models;
|
||||||
|
|
||||||
namespace Orchard.Packaging.ViewModels {
|
namespace Orchard.Packaging.ViewModels {
|
||||||
public class PackagingListViewModel {
|
public class PackagingListViewModel {
|
||||||
|
public DateTime? LastUpdateCheckUtc { get; set; }
|
||||||
public IEnumerable<UpdatePackageEntry> Entries { get; set; }
|
public IEnumerable<UpdatePackageEntry> Entries { get; set; }
|
||||||
public dynamic Pager { get; set; }
|
public dynamic Pager { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<fieldset class="update-actions">
|
<fieldset class="update-actions">
|
||||||
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" >@T("Refresh")</a>
|
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(dateTimeUtc: Model.LastUpdateCheckUtc.Value))">@T("Check for Updates")</a>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
@if (Model.Entries.Count() <= 0) {
|
@if (Model.Entries.Count() <= 0) {
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<fieldset class="update-actions">
|
||||||
|
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(dateTimeUtc: Model.LastUpdateCheckUtc.Value))" >@T("Check for Updates")</a>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
@if (Model.Entries.Count() <= 0) {
|
@if (Model.Entries.Count() <= 0) {
|
||||||
<p>@T("No theme updates available.").ToString()</p>
|
<p>@T("No theme updates available.").ToString()</p>
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user