Add option to enable/disable caching on template download

pull/1375/head
Halil İbrahim Kalkan 6 years ago
parent 2f39d2a15b
commit a694ab2dff

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

@ -49,7 +49,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
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);
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);
}

Loading…
Cancel
Save