mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#17553 / #17464: Avoid to get the screenshots for the packages everytime a package information is downloaded from the gallery.
--HG-- branch : 1.x
This commit is contained in:
@@ -126,7 +126,7 @@ Features:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<PackagingEntry> GetExtensionList(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 new[] {
|
||||
new PackagingEntry {
|
||||
PackageId = "Orchard.Module.SuperWiki",
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Orchard.Packaging.Controllers {
|
||||
int totalCount = 0;
|
||||
foreach (var source in sources) {
|
||||
try {
|
||||
var sourceExtensions = _packagingSourceManager.GetExtensionList(
|
||||
var sourceExtensions = _packagingSourceManager.GetExtensionList(true,
|
||||
source,
|
||||
packages => {
|
||||
packages = packages.Where(p => p.PackageType == packageType &&
|
||||
|
||||
@@ -32,10 +32,11 @@ namespace Orchard.Packaging.Services {
|
||||
/// <summary>
|
||||
/// Retrieves the list of extensions from a feed source.
|
||||
/// </summary>
|
||||
/// <param name="includeScreenshots">Specifies if screenshots should be included in the result.</param>
|
||||
/// <param name="packagingSource">The packaging source from where to get the extensions.</param>
|
||||
/// <param name="query">The optional query to retrieve the extensions.</param>
|
||||
/// <returns>The list of extensions.</returns>
|
||||
IEnumerable<PackagingEntry> GetExtensionList(PackagingSource packagingSource = null, Func<IQueryable<PublishedPackage>, IQueryable<PublishedPackage>> query = null);
|
||||
IEnumerable<PackagingEntry> GetExtensionList(bool includeScreenshots, PackagingSource packagingSource = null, Func<IQueryable<PublishedPackage>, IQueryable<PublishedPackage>> query = null);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the number of extensions from a feed source.
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Orchard.Packaging.Services {
|
||||
GetOrAddEntry(list, packageId).ExtensionsDescriptor = extension;
|
||||
}
|
||||
|
||||
var packages = _packagingSourceManager.GetExtensionList(packagingSource)
|
||||
var packages = _packagingSourceManager.GetExtensionList(false, packagingSource)
|
||||
.ToList()
|
||||
.GroupBy(p => p.PackageId, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -64,10 +64,11 @@ namespace Orchard.Packaging.Services {
|
||||
/// <summary>
|
||||
/// Retrieves the list of extensions from a feed source.
|
||||
/// </summary>
|
||||
/// <param name="includeScreenshots">Specifies if screenshots should be included in the result.</param>
|
||||
/// <param name="packagingSource">The packaging source from where to get the extensions.</param>
|
||||
/// <param name="query">The optional query to retrieve the extensions.</param>
|
||||
/// <returns>The list of extensions.</returns>
|
||||
public IEnumerable<PackagingEntry> GetExtensionList(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})
|
||||
.SelectMany(
|
||||
source => {
|
||||
@@ -80,10 +81,12 @@ namespace Orchard.Packaging.Services {
|
||||
|
||||
return packages.ToList().Select(
|
||||
p => {
|
||||
PublishedScreenshot firstScreenshot = galleryFeedContext.Screenshots
|
||||
.Where(s => s.PublishedPackageId == p.Id && s.PublishedPackageVersion == p.Version)
|
||||
.ToList()
|
||||
.FirstOrDefault();
|
||||
PublishedScreenshot firstScreenshot = includeScreenshots
|
||||
? galleryFeedContext.Screenshots
|
||||
.Where(s => s.PublishedPackageId == p.Id && s.PublishedPackageVersion == p.Version)
|
||||
.ToList()
|
||||
.FirstOrDefault()
|
||||
: null;
|
||||
return CreatePackageEntry(p, firstScreenshot, packagingSource, galleryFeedContext.GetReadStreamUri(p));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
}
|
||||
|
||||
if (enforceVersion) {
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(packagingSource,
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(false, packagingSource,
|
||||
packages => packages.Where(package =>
|
||||
package.PackageType.Equals(DefaultExtensionTypes.Module) &&
|
||||
package.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase) &&
|
||||
package.Version.Equals(version, StringComparison.OrdinalIgnoreCase))).FirstOrDefault();
|
||||
}
|
||||
else {
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(packagingSource,
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(false, packagingSource,
|
||||
packages => packages.Where(package =>
|
||||
package.PackageType.Equals(DefaultExtensionTypes.Module) &&
|
||||
package.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase) &&
|
||||
|
||||
@@ -86,14 +86,14 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
}
|
||||
|
||||
if (enforceVersion) {
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(packagingSource,
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(false, packagingSource,
|
||||
packages => packages.Where(package =>
|
||||
package.PackageType.Equals(DefaultExtensionTypes.Theme) &&
|
||||
package.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase) &&
|
||||
package.Version.Equals(version, StringComparison.OrdinalIgnoreCase))).FirstOrDefault();
|
||||
}
|
||||
else {
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(packagingSource,
|
||||
packagingEntry = _packagingSourceManager.GetExtensionList(false, packagingSource,
|
||||
packages => packages.Where(package =>
|
||||
package.PackageType.Equals(DefaultExtensionTypes.Theme) &&
|
||||
package.Id.Equals(packageId, StringComparison.OrdinalIgnoreCase) &&
|
||||
|
||||
Reference in New Issue
Block a user