diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2022-09-16 16:38:56 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2022-09-16 16:40:44 +0300 |
commit | 315a78929024c25babd0a8add955d48789d0e8f1 (patch) | |
tree | 018c869d8830ae3ebab1ee60aaf0334a9e906a26 | |
parent | db16db989336e58eaa76963e77ce324587f7f43c (diff) |
Try to make code a bit more clear
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/AddinRegistryUpdater.cs | 13 | ||||
-rw-r--r-- | Test/UnitTests/TestScanDataFileGeneration.cs | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinRegistryUpdater.cs b/Mono.Addins/Mono.Addins.Database/AddinRegistryUpdater.cs index 760c4e8..5d3b91d 100644 --- a/Mono.Addins/Mono.Addins.Database/AddinRegistryUpdater.cs +++ b/Mono.Addins/Mono.Addins.Database/AddinRegistryUpdater.cs @@ -50,6 +50,12 @@ namespace Mono.Addins.Database { AddinScanFolderInfo folderInfo; + AddinScanFolderInfo previousOldFolderInfo = oldFolderInfo; + + // Don't reset oldFolderInfo here. When scanning a folder that had scan index and now it doesn't, + // we need to keep the old folder data since the root folder info had the info for all folders + // in the domain. + if (!database.GetFolderInfoForPath (monitor, path, out folderInfo)) { // folderInfo file was corrupt. // Just in case, we are going to regenerate all relation data. @@ -76,7 +82,6 @@ namespace Mono.Addins.Database bool sharedFolder = domain == AddinDatabase.GlobalDomain; bool isNewFolder = folderInfo == null; bool folderHasIndex = dirScanDataIndex != null; - bool oldFolderInfoWasSet = false; if (isNewFolder) { // No folder info. It is the first time this folder is scanned. @@ -90,11 +95,10 @@ namespace Mono.Addins.Database // Keep a copy of the old folder info, to be used to retrieve the old status of the add-ins. oldFolderInfo = folderInfo; - oldFolderInfoWasSet = true; folderInfo = new AddinScanFolderInfo (oldFolderInfo); + scanResult.RegenerateRelationData = true; folderInfo.Reset (); - scanResult.RegisterModifiedFolderInfo (folderInfo); folderInfo.FolderHasScanDataIndex = folderHasIndex; } @@ -186,8 +190,7 @@ namespace Mono.Addins.Database UpdateDeletedAddins (monitor, oldFolderInfo ?? currentFolderInfo); - if (oldFolderInfoWasSet) - oldFolderInfo = null; + oldFolderInfo = previousOldFolderInfo; } protected override void OnVisitAddinManifestFile (IProgressStatus monitor, string file) diff --git a/Test/UnitTests/TestScanDataFileGeneration.cs b/Test/UnitTests/TestScanDataFileGeneration.cs index 8fb64a7..3c68ced 100644 --- a/Test/UnitTests/TestScanDataFileGeneration.cs +++ b/Test/UnitTests/TestScanDataFileGeneration.cs @@ -233,10 +233,10 @@ namespace UnitTests } [Test] - [TestCase (true, true, TestName = "DowngradeAddins - with scan data")] - [TestCase (true, false, TestName = "DowngradeAddins - from scan to no scan data")] - [TestCase (false, true, TestName = "DowngradeAddins - from no scan to scan data")] - [TestCase (false, false, TestName = "DowngradeAddins - with no scan data")] + [TestCase (true, true, TestName = "DowngradeAddins - with scan index")] + [TestCase (true, false, TestName = "DowngradeAddins - from scan to no scan index")] + [TestCase (false, true, TestName = "DowngradeAddins - from no scan to scan index")] + [TestCase (false, false, TestName = "DowngradeAddins - with no scan index")] public void DowngradeAddins (bool hasScaIndexBefore, bool hasScanIndexAfter) { // Tests that the database is properly updated when add-ins are downgraded. |