From 6b3192ee3b33c517ec7f4d438724047077619bf8 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:24:11 +0300 Subject: [PATCH] CLI: Should use the cached template if the template source specified. --- .../Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs index acdfa29bb09..7bfb0943c37 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs @@ -160,11 +160,10 @@ public async Task GetAsync( var nugetVersion = version; - var localCacheFile = Path.Combine(CliPaths.TemplateCache, name.Replace("/", ".") + ".zip"); #if DEBUG - if (File.Exists(localCacheFile)) + if (File.Exists(localCacheFile) && templateSource.IsNullOrWhiteSpace()) { return new TemplateFile(File.ReadAllBytes(localCacheFile), version, latestVersion, nugetVersion); } @@ -176,6 +175,16 @@ public async Task GetAsync( return new TemplateFile(File.ReadAllBytes(localCacheFile), version, latestVersion, nugetVersion); } + if (!skipCache && !templateSource.IsNullOrWhiteSpace() && type == SourceCodeTypes.Template) + { + var templateFilePath = templateSource.EndsWith(".zip") + ? templateSource + : Path.Combine(templateSource, name.Replace("/", ".").EnsureEndsWith('-') + version + ".zip"); + + Logger.LogInformation("Using cached template: " + name + ", version: " + version + " from template source: " + templateFilePath); + return new TemplateFile(File.ReadAllBytes(templateFilePath), version, latestVersion, nugetVersion); + } + Logger.LogInformation("Downloading " + type + ": " + name + ", version: " + version); var fileContent = await DownloadSourceCodeContentAsync(