Browse Source

Add option to enable/disable caching on template download

pull/1375/head
Halil İbrahim Kalkan 7 years ago
parent
commit
a694ab2dff
  1. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs
  2. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoTemplateStore.cs

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs

@ -7,6 +7,11 @@ namespace Volo.Abp.Cli
{ {
public Dictionary<string, Type> Commands { get; } public Dictionary<string, Type> Commands { get; }
/// <summary>
/// Default value: true.
/// </summary>
public bool CacheTemplates { get; set; } = true;
public CliOptions() public CliOptions()
{ {
Commands = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase); Commands = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoTemplateStore.cs

@ -49,7 +49,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache); DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
var localCacheFile = Path.Combine(CliPaths.TemplateCache, name + "-" + version + ".zip"); var localCacheFile = Path.Combine(CliPaths.TemplateCache, name + "-" + version + ".zip");
if (File.Exists(localCacheFile)) if (Options.CacheTemplates && File.Exists(localCacheFile))
{ {
Logger.LogInformation("Using cached template: " + name + ", version: " + version); Logger.LogInformation("Using cached template: " + name + ", version: " + version);
return new TemplateFile(File.ReadAllBytes(localCacheFile), version); return new TemplateFile(File.ReadAllBytes(localCacheFile), version);
@ -67,7 +67,10 @@ namespace Volo.Abp.Cli.ProjectBuilding
} }
); );
File.WriteAllBytes(localCacheFile, fileContent); if (Options.CacheTemplates)
{
File.WriteAllBytes(localCacheFile, fileContent);
}
return new TemplateFile(fileContent, version); return new TemplateFile(fileContent, version);
} }

Loading…
Cancel
Save