Skip to content

Commit fa0c945

Browse files
committed
Use a private field to tell if packages folder was custom
1 parent 83df5ad commit fa0c945

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Weikio.PluginFramework.Catalogs.NuGet/NugetPackagePluginCatalog.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class NugetPackagePluginCatalog : IPluginCatalog
2626

2727
public string PackagesFolder { get; }
2828

29+
private bool _isCustomPackagesFolder;
30+
2931
public NugetPackagePluginCatalog(string packageName, string packageVersion = null, bool includePrerelease = false, NuGetFeed packageFeed = null,
3032
string packagesFolder = null, Action<TypeFinderCriteriaBuilder> configureFinder = null, Dictionary<string, TypeFinderCriteria> criterias = null,
3133
NugetPluginCatalogOptions options = null)
@@ -37,6 +39,8 @@ public NugetPackagePluginCatalog(string packageName, string packageVersion = nul
3739

3840
PackagesFolder = packagesFolder ?? Path.Combine(Path.GetTempPath(), "NugetPackagePluginCatalog", Path.GetRandomFileName());
3941

42+
_isCustomPackagesFolder = packagesFolder != null;
43+
4044
if (!Directory.Exists(PackagesFolder))
4145
{
4246
Directory.CreateDirectory(PackagesFolder);
@@ -95,7 +99,7 @@ public async Task Initialize()
9599
{
96100
NugetDownloadResult nugetDownloadResult = null;
97101

98-
if (File.Exists(PackagesFolder + "/nugetDownloadResult.json"))
102+
if (_isCustomPackagesFolder && File.Exists(PackagesFolder + "/nugetDownloadResult.json"))
99103
{
100104
var jsonFromDisk = await File.ReadAllTextAsync(PackagesFolder + "/nugetDownloadResult.json");
101105

@@ -142,7 +146,7 @@ public async Task Initialize()
142146

143147
IsInitialized = true;
144148

145-
if (File.Exists(PackagesFolder + "/nugetDownloadResult.json") == false)
149+
if (_isCustomPackagesFolder && File.Exists(PackagesFolder + "/nugetDownloadResult.json") == false)
146150
{
147151
var jsonToWrite = JsonConvert.SerializeObject(nugetDownloadResult);
148152

0 commit comments

Comments
 (0)