Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Remove unused media settings - storeLocation

support4414e6ea69d4
diff --git a/src/Business/Grand.Business.Core/Interfaces/Storage/IFileStore.cs b/src/Business/Grand.Business.Core/Interfaces/Storage/IFileStore.cs
index 4b391ddca..136bca181 100644
--- a/src/Business/Grand.Business.Core/Interfaces/Storage/IFileStore.cs
+++ b/src/Business/Grand.Business.Core/Interfaces/Storage/IFileStore.cs
@@ -147,15 +147,14 @@ namespace Grand.Business.Core.Interfaces.Storage
var normalizedParts =
paths
.Select(x => fileStore.NormalizePath(x))
- .Where(x => !String.IsNullOrEmpty(x))
+ .Where(x => !string.IsNullOrEmpty(x))
.ToArray();
-
- var combined = String.Join("/", normalizedParts);
-
- // Preserve the initial '/' if it's present.
- if (paths[0]?.StartsWith('/') == true)
+
+ var combined = string.Join("/", normalizedParts);
+ if (!Path.IsPathRooted(combined))
+ {
combined = "/" + combined;
-
+ }
return combined;
}
diff --git a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
index 8eade3e1b..371816e06 100644
--- a/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/AmazonPictureService.cs
@@ -34,7 +34,6 @@ namespace Grand.Business.Storage.Services
public AmazonPictureService(IRepository<Picture> pictureRepository,
ILogger logger,
IMediator mediator,
- IWorkContext workContext,
ICacheBase cacheBase,
IMediaFileStore mediaFileStore,
MediaSettings mediaSettings,
@@ -43,7 +42,6 @@ namespace Grand.Business.Storage.Services
: base(pictureRepository,
logger,
mediator,
- workContext,
cacheBase,
mediaFileStore,
mediaSettings,
diff --git a/src/Business/Grand.Business.Storage/Services/AzurePictureService.cs b/src/Business/Grand.Business.Storage/Services/AzurePictureService.cs
index bb48e9918..4f3a39bb5 100644
--- a/src/Business/Grand.Business.Storage/Services/AzurePictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/AzurePictureService.cs
@@ -30,7 +30,6 @@ namespace Grand.Business.Storage.Services
public AzurePictureService(IRepository<Picture> pictureRepository,
ILogger logger,
IMediator mediator,
- IWorkContext workContext,
ICacheBase cacheBase,
IMediaFileStore mediaFileStore,
MediaSettings mediaSettings,
@@ -41,7 +40,6 @@ namespace Grand.Business.Storage.Services
: base(pictureRepository,
logger,
mediator,
- workContext,
cacheBase,
mediaFileStore,
mediaSettings,
diff --git a/src/Business/Grand.Business.Storage/Services/PictureService.cs b/src/Business/Grand.Business.Storage/Services/PictureService.cs
index 0d17ff381..6f3af1cb1 100644
--- a/src/Business/Grand.Business.Storage/Services/PictureService.cs
+++ b/src/Business/Grand.Business.Storage/Services/PictureService.cs
@@ -5,7 +5,6 @@ using Grand.Domain;
using Grand.Domain.Common;
using Grand.Domain.Data;
using Grand.Domain.Media;
-using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
using Grand.Infrastructure.Caching.Constants;
using Grand.Infrastructure.Extensions;
@@ -27,7 +26,6 @@ namespace Grand.Business.Storage.Services
private readonly IRepository<Picture> _pictureRepository;
private readonly ILogger _logger;
private readonly IMediator _mediator;
- private readonly IWorkContext _workContext;
private readonly ICacheBase _cacheBase;
private readonly IMediaFileStore _mediaFileStore;
private readonly MediaSettings _mediaSettings;
@@ -43,7 +41,6 @@ namespace Grand.Business.Storage.Services
/// <param name="pictureRepository">Picture repository</param>
/// <param name="logger">Logger</param>
/// <param name="mediator">Mediator</param>
- /// <param name="workContext">Current context</param>
/// <param name="cacheBase">Cache manager</param>
/// <param name="mediaFileStore">Media file storage</param>
/// <param name="mediaSettings">Media settings</param>
@@ -51,7 +48,6 @@ namespace Grand.Business.Storage.Services
public PictureService(IRepository<Picture> pictureRepository,
ILogger logger,
IMediator mediator,
- IWorkContext workContext,
ICacheBase cacheBase,
IMediaFileStore mediaFileStore,
MediaSettings mediaSettings,
@@ -60,7 +56,6 @@ namespace Grand.Business.Storage.Services
_pictureRepository = pictureRepository;
_logger = logger;
_mediator = mediator;
- _workContext = workContext;
_cacheBase = cacheBase;
_mediaFileStore = mediaFileStore;
_mediaSettings = mediaSettings;
@@ -161,12 +156,7 @@ namespace Grand.Business.Storage.Services
/// <returns>Local picture thumb path</returns>
protected virtual string GetThumbUrl(string thumbFileName, string storeLocation = null)
{
- storeLocation = !string.IsNullOrEmpty(storeLocation)
- ? storeLocation
- : string.IsNullOrEmpty(_mediaSettings.StoreLocation) ?
- _workContext.CurrentStore.SslEnabled ? _workContext.CurrentStore.SecureUrl : _workContext.CurrentStore.Url :
- _mediaSettings.StoreLocation;
-
+ storeLocation = !string.IsNullOrEmpty(storeLocation) ? storeLocation : "";
return _mediaFileStore.Combine(storeLocation, CommonPath.Param, CommonPath.ImageThumbPath, thumbFileName);
}
@@ -268,15 +258,12 @@ namespace Grand.Business.Storage.Services
var filePath = await GetPicturePhysicalPath(_mediaSettings.DefaultImageName);
if (string.IsNullOrEmpty(filePath))
{
- return _mediaFileStore.Combine(_mediaSettings.StoreLocation, CommonPath.ImagePath, "no-image.png");
+ return _mediaFileStore.Combine(CommonPath.ImagePath, "no-image.png");
}
if (targetSize == 0)
{
return !string.IsNullOrEmpty(storeLocation)
- ? storeLocation
- : string.IsNullOrEmpty(_mediaSettings.StoreLocation) ?
- _workContext.CurrentStore.SslEnabled ? _workContext.CurrentStore.SecureUrl : _workContext.CurrentStore.Url :
- _mediaFileStore.Combine(_mediaSettings.StoreLocation, CommonPath.ImagePath, _mediaSettings.DefaultImageName);
+ ? storeLocation : _mediaFileStore.Combine(CommonPath.ImagePath, _mediaSettings.DefaultImageName);
}
var fileExtension = Path.GetExtension(filePath);
@@ -315,7 +302,7 @@ namespace Grand.Business.Storage.Services
bool showDefaultPicture = true,
string storeLocation = null)
{
- var pictureKey = string.Format(CacheKey.PICTURE_BY_KEY, pictureId, _workContext.CurrentStore?.Id, targetSize, showDefaultPicture, storeLocation);
+ var pictureKey = string.Format(CacheKey.PICTURE_BY_KEY, pictureId, targetSize, showDefaultPicture, storeLocation);
return await _cacheBase.GetAsync(pictureKey, async () =>
{
var picture = await GetPictureById(pictureId);
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
index e3bc67186..a190019fe 100644
--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs
@@ -89,7 +89,6 @@ namespace Grand.Business.System.Services.Installation
ImageQuality = 100,
DefaultPictureZoomEnabled = true,
AllowedFileTypes = ".gif, .jpg, .jpeg, .png, .bmp, .webp",
- StoreLocation = "/"
});
await _settingService.SaveSetting(new StorageSettings {
diff --git a/src/Core/Grand.Domain/Media/MediaSettings.cs b/src/Core/Grand.Domain/Media/MediaSettings.cs
index 1eb59798f..f50220537 100644
--- a/src/Core/Grand.Domain/Media/MediaSettings.cs
+++ b/src/Core/Grand.Domain/Media/MediaSettings.cs
@@ -36,7 +36,5 @@ namespace Grand.Domain.Media
public string FileManagerDisabledUICommands { get; set; } = "ping,hide,archive,extract,netmount,netunmount,zipdl";
- public string StoreLocation { get; set; }
-
}
}
\ No newline at end of file
diff --git a/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs b/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
index 13d358f18..e5a5d658d 100644
--- a/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
+++ b/src/Core/Grand.Infrastructure/Caching/Constants/CommonCacheKey.cs
@@ -117,12 +117,11 @@
/// </summary>
/// <remarks>
/// {0} : picture ID
- /// {1} : store ID
- /// {2} : target size
- /// {3} : showDefaultPicture
- /// {4} : storeLocation
+ /// {1} : target size
+ /// {2} : showDefaultPicture
+ /// {3} : storeLocation
/// </remarks>
- public static string PICTURE_BY_KEY => "Grand.picture-{0}-{1}-{2}-{3}-{4}";
+ public static string PICTURE_BY_KEY => "Grand.picture-{0}-{1}-{2}-{3}";
#region Seo
diff --git a/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs b/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs
index fbe283514..65f31fb5e 100644
--- a/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs
+++ b/src/Tests/Grand.Business.Storage.Tests/Services/PictureServiceTests.cs
@@ -40,8 +40,7 @@ namespace Grand.Business.Storage.Tests.Services
_mediaFileStoreMock = new Mock<IMediaFileStore>();
_settings = new MediaSettings();
_storagesettings = new StorageSettings();
- _service = new PictureService(_repoMock.Object, _logerMock.Object, _mediatorMock.Object, _workContextMock.Object
- , _cacheMock.Object, _mediaFileStoreMock.Object, _settings, _storagesettings);
+ _service = new PictureService(_repoMock.Object, _logerMock.Object, _mediatorMock.Object, _cacheMock.Object, _mediaFileStoreMock.Object, _settings, _storagesettings);
}
[TestMethod]
public async Task GetPictureById_InvokeExpectedMethods()
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Media.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Media.cshtml
index b0fb60569..0783b16a7 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Media.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Media.cshtml
@@ -269,15 +269,6 @@
<span asp-validation-for="DefaultImageName"></span>
</div>
</div>
- <div class="form-group">
- <div class="col-8 col-md-4 col-sm-4 text-right">
- <admin-label asp-for="StoreLocation" class="control-label" />
- </div>
- <div class="col-4 col-md-8 col-sm-8">
- <admin-input asp-for="StoreLocation" />
- <span asp-validation-for="StoreLocation"></span>
- </div>
- </div>
</div>
</div>
<vc:admin-widget widget-zone="media_settings_bottom" additional-data="null" />
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/MediaSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/MediaSettingsModel.cs
index 015884a12..eae1f13b1 100644
--- a/src/Web/Grand.Web.Admin/Models/Settings/MediaSettingsModel.cs
+++ b/src/Web/Grand.Web.Admin/Models/Settings/MediaSettingsModel.cs
@@ -82,10 +82,7 @@ namespace Grand.Web.Admin.Models.Settings
[GrandResourceDisplayName("Admin.Settings.Media.FileManagerDisabledUICommands")]
public string FileManagerDisabledUICommands { get; set; }
-
- [GrandResourceDisplayName("Admin.Settings.Media.StoreLocation")]
- public string StoreLocation { get; set; }
-
+
[GrandResourceDisplayName("Admin.Settings.Media.DefaultImageName")]
public string DefaultImageName { get; set; } = "no-image.png";
diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
index 25e499405..46be1ce3d 100644
--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
@@ -10914,12 +10914,6 @@
<Resource Name="Admin.Settings.Media.ProductThumbPictureSizeOnProductDetailsPage" Area="Admin">
<Value>Product thumbnail image size (product page)</Value>
</Resource>
- <Resource Name="Admin.Settings.Media.StoreLocation" Area="Admin">
- <Value>Image location (url)</Value>
- </Resource>
- <Resource Name="Admin.Settings.Media.StoreLocation.hint" Area="Admin">
- <Value>This settings is only for advanced user</Value>
- </Resource>
<Resource Name="Admin.Settings.Media.VendorThumbPictureSize" Area="Admin">
<Value>Vendor thumbnail image size</Value>
</Resource>