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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Refactor CommonPath and update PluginController
KrzysztofPajak06d0b1da0757
diff --git a/src/Core/Grand.SharedKernel/Extensions/CommonPath.cs b/src/Core/Grand.SharedKernel/Extensions/CommonPath.csindex 9f70aaa5a..4d4812e77 100644--- a/src/Core/Grand.SharedKernel/Extensions/CommonPath.cs+++ b/src/Core/Grand.SharedKernel/Extensions/CommonPath.cs@@ -6,6 +6,10 @@ public static class CommonPathpublic static string Plugins => "Plugins";+ public static string TmpUploadPath = "TempUploads";++ public static string DirectoryParam = "Directory";+/// <summary>/// Extra parameter to path/// </summary>@@ -23,13 +27,7 @@ public static class CommonPath/// <returns>The physical path.</returns>public static string InstalledPluginsFilePath =>Path.Combine(BaseDirectory, AppData, Param, "InstalledPlugins.cfg");-- /// <summary>- /// Maps a temp upload path to a physical disk path.- /// </summary>- /// <returns>The physical path.</returns>- public static string TmpUploadPath => Path.Combine(BaseDirectory, AppData, Param, "TempUploads");-+/// <summary>/// Gets or sets application base path/// </summary>diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.csindex 42b024c7c..6ddc55249 100644--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs@@ -274,7 +274,7 @@ public class PluginController(Error(translationService.GetResource("Admin.Common.UploadFile"));return RedirectToAction("List");}-+ var tempDirectory = Path.Combine(webHostEnvironment.ContentRootPath, CommonPath.Plugins, CommonPath.TmpUploadPath);var zipFilePath = "";try{@@ -282,7 +282,6 @@ public class PluginController(throw new Exception("Only zip archives are supported");//ensure that temp directory is created- var tempDirectory = CommonPath.TmpUploadPath;Directory.CreateDirectory(new DirectoryInfo(tempDirectory).FullName);//copy original archive to the temp directory@@ -300,8 +299,8 @@ public class PluginController(finally{//delete temporary file- if (!string.IsNullOrEmpty(zipFilePath))- System.IO.File.Delete(zipFilePath);+ if(Directory.Exists(tempDirectory))+ DeleteDirectory(tempDirectory);}logger.LogInformation("The plugin has been uploaded by the user {CurrentCustomerEmail}",