From 1be4acac8103c9c7862301122e45b5196d7e502a Mon Sep 17 00:00:00 2001 From: Tyrie Vella Date: Wed, 8 Apr 2026 16:17:10 -0700 Subject: [PATCH] Remove GVFS.GVFlt and ESENT legacy disk layout upgrades MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the GVFlt compatibility shim project (legacy ProjFS predecessor) and all DiskLayout upgrade paths that depend on ManagedEsent (layouts 7→8, 8→9, 9→10, 10→11, 11→12, 12→12.1, 12→13, 13→14). These upgrades are 6+ years old and no longer needed. Raise minimum supported disk layout version from 7 to 14. The 14→15 upgrade (ModifiedPaths) is retained so v14 repos can still upgrade. Users on layouts below 14 must upgrade through an intermediate GVFS version first. Removes ManagedEsent, Microsoft.Database.Collections.Generic, and Microsoft.Database.Isam NuGet packages entirely. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella --- Directory.Packages.props | 3 - GVFS.sln | 6 - GVFS/FastFetch/FastFetch.csproj | 1 - .../GVFS.FunctionalTests.csproj | 1 - .../GVFS.FunctionalTests/Tools/GVFSHelpers.cs | 2 +- .../Windows/Tests/SharedCacheUpgradeTests.cs | 111 ----------- .../Tests/WindowsDiskLayoutUpgradeTests.cs | 186 +----------------- .../Windows/Tools/ESENTDatabase.cs | 71 ------- GVFS/GVFS.GVFlt/GVFS.GVFlt.csproj | 11 -- GVFS/GVFS.GVFlt/GVFltCallbacks.cs | 34 ---- GVFS/GVFS.Payload/GVFS.Payload.csproj | 1 - ...iskLayout10to11Upgrade_NewOperationType.cs | 27 --- ...iskLayout11to12Upgrade_SharedLocalCache.cs | 63 ------ ...yout12_0To12_1Upgrade_StatusAheadBehind.cs | 35 ---- ...skLayout12to13Upgrade_FolderPlaceholder.cs | 123 ------------ .../DiskLayout13to14Upgrade_BlobSizes.cs | 139 ------------- .../DiskLayout7to8Upgrade_NewOperationType.cs | 42 ---- ...iskLayout8to9Upgrade_RepoMetadataToJson.cs | 89 --------- ...BackgroundAndPlaceholderListToFileBased.cs | 181 ----------------- .../WindowsDiskLayoutUpgradeData.cs | 42 +--- .../GVFS.Platform.Windows.csproj | 4 - 21 files changed, 7 insertions(+), 1165 deletions(-) delete mode 100644 GVFS/GVFS.FunctionalTests/Windows/Tools/ESENTDatabase.cs delete mode 100644 GVFS/GVFS.GVFlt/GVFS.GVFlt.csproj delete mode 100644 GVFS/GVFS.GVFlt/GVFltCallbacks.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout10to11Upgrade_NewOperationType.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout11to12Upgrade_SharedLocalCache.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12_0To12_1Upgrade_StatusAheadBehind.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12to13Upgrade_FolderPlaceholder.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout13to14Upgrade_BlobSizes.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout7to8Upgrade_NewOperationType.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout8to9Upgrade_RepoMetadataToJson.cs delete mode 100644 GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 2e1b042d8..744acfb94 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,10 +12,7 @@ - - - diff --git a/GVFS.sln b/GVFS.sln index 80a2cbf0e..f4847cd29 100644 --- a/GVFS.sln +++ b/GVFS.sln @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.FunctionalTests", "GVF EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.FunctionalTests.LockHolder", "GVFS\GVFS.FunctionalTests.LockHolder\GVFS.FunctionalTests.LockHolder.csproj", "{B26985C3-250A-4805-AA97-AD0604331AC7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.GVFlt", "GVFS\GVFS.GVFlt\GVFS.GVFlt.csproj", "{B366D3B6-1E85-4015-8DB0-D5FA4331ECE4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.Hooks", "GVFS\GVFS.Hooks\GVFS.Hooks.csproj", "{EDB4A40E-CFC9-486A-BDC5-AB2951FD8EDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GVFS.Mount", "GVFS\GVFS.Mount\GVFS.Mount.csproj", "{F96089C2-6D09-4349-B65D-9CCA6160C6A5}" @@ -75,10 +73,6 @@ Global {B26985C3-250A-4805-AA97-AD0604331AC7}.Debug|x64.Build.0 = Debug|Any CPU {B26985C3-250A-4805-AA97-AD0604331AC7}.Release|x64.ActiveCfg = Release|Any CPU {B26985C3-250A-4805-AA97-AD0604331AC7}.Release|x64.Build.0 = Release|Any CPU - {B366D3B6-1E85-4015-8DB0-D5FA4331ECE4}.Debug|x64.ActiveCfg = Debug|Any CPU - {B366D3B6-1E85-4015-8DB0-D5FA4331ECE4}.Debug|x64.Build.0 = Debug|Any CPU - {B366D3B6-1E85-4015-8DB0-D5FA4331ECE4}.Release|x64.ActiveCfg = Release|Any CPU - {B366D3B6-1E85-4015-8DB0-D5FA4331ECE4}.Release|x64.Build.0 = Release|Any CPU {EDB4A40E-CFC9-486A-BDC5-AB2951FD8EDC}.Debug|x64.ActiveCfg = Debug|Any CPU {EDB4A40E-CFC9-486A-BDC5-AB2951FD8EDC}.Debug|x64.Build.0 = Debug|Any CPU {EDB4A40E-CFC9-486A-BDC5-AB2951FD8EDC}.Release|x64.ActiveCfg = Release|Any CPU diff --git a/GVFS/FastFetch/FastFetch.csproj b/GVFS/FastFetch/FastFetch.csproj index a2584da8b..cb75afee8 100644 --- a/GVFS/FastFetch/FastFetch.csproj +++ b/GVFS/FastFetch/FastFetch.csproj @@ -20,7 +20,6 @@ Microsoft400 diff --git a/GVFS/GVFS.FunctionalTests/GVFS.FunctionalTests.csproj b/GVFS/GVFS.FunctionalTests/GVFS.FunctionalTests.csproj index e11eab0dc..daf852167 100644 --- a/GVFS/GVFS.FunctionalTests/GVFS.FunctionalTests.csproj +++ b/GVFS/GVFS.FunctionalTests/GVFS.FunctionalTests.csproj @@ -9,7 +9,6 @@ - diff --git a/GVFS/GVFS.FunctionalTests/Tools/GVFSHelpers.cs b/GVFS/GVFS.FunctionalTests/Tools/GVFSHelpers.cs index d079e3668..b15d66eed 100644 --- a/GVFS/GVFS.FunctionalTests/Tools/GVFSHelpers.cs +++ b/GVFS/GVFS.FunctionalTests/Tools/GVFSHelpers.cs @@ -36,7 +36,7 @@ public static class GVFSHelpers private const int WindowsCurrentDiskLayoutMajorVersion = 19; private const int MacCurrentDiskLayoutMajorVersion = 19; - private const int WindowsCurrentDiskLayoutMinimumMajorVersion = 7; + private const int WindowsCurrentDiskLayoutMinimumMajorVersion = 14; private const int MacCurrentDiskLayoutMinimumMajorVersion = 18; public static string ConvertPathToGitFormat(string path) diff --git a/GVFS/GVFS.FunctionalTests/Windows/Tests/SharedCacheUpgradeTests.cs b/GVFS/GVFS.FunctionalTests/Windows/Tests/SharedCacheUpgradeTests.cs index 3025b443e..e6432ed41 100644 --- a/GVFS/GVFS.FunctionalTests/Windows/Tests/SharedCacheUpgradeTests.cs +++ b/GVFS/GVFS.FunctionalTests/Windows/Tests/SharedCacheUpgradeTests.cs @@ -3,11 +3,9 @@ using GVFS.FunctionalTests.Tests.MultiEnlistmentTests; using GVFS.FunctionalTests.Tools; using GVFS.FunctionalTests.Windows.Tests; -using GVFS.FunctionalTests.Windows.Tools; using GVFS.Tests.Should; using NUnit.Framework; using System; -using System.Collections.Generic; using System.IO; namespace GVFS.FunctionalTests.Windows.Windows.Tests @@ -33,115 +31,6 @@ public void SetCacheLocation() this.localCachePath = Path.Combine(this.localCacheParentPath, ".customGVFSCache"); } - [TestCase] - public void MountUpgradesLocalSizesToSharedCache() - { - GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment(); - enlistment.UnmountGVFS(); - - string localCacheRoot = GVFSHelpers.GetPersistedLocalCacheRoot(enlistment.DotGVFSRoot); - string gitObjectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot); - - // Delete the existing repo metadata - string versionJsonPath = Path.Combine(enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - // Since there isn't a sparse-checkout file that is used anymore one needs to be added - // in order to test the old upgrades that might have needed it - string sparseCheckoutPath = Path.Combine(enlistment.RepoRoot, TestConstants.DotGit.Info.SparseCheckoutPath); - this.fileSystem.WriteAllText(sparseCheckoutPath, "/.gitattributes\r\n"); - - // "13.0" was the last version before blob sizes were moved out of Esent - string metadataPath = Path.Combine(enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - this.fileSystem.CreateEmptyFile(metadataPath); - GVFSHelpers.SaveDiskLayoutVersion(enlistment.DotGVFSRoot, "13", "0"); - GVFSHelpers.SaveLocalCacheRoot(enlistment.DotGVFSRoot, localCacheRoot); - GVFSHelpers.SaveGitObjectsRoot(enlistment.DotGVFSRoot, gitObjectsRoot); - - // Create a legacy PersistedDictionary sizes database - List> entries = new List>() - { - new KeyValuePair(new string('0', 40), 1), - new KeyValuePair(new string('1', 40), 2), - new KeyValuePair(new string('2', 40), 4), - new KeyValuePair(new string('3', 40), 8), - }; - - ESENTDatabase.CreateEsentBlobSizesDatabase(enlistment.DotGVFSRoot, entries); - - enlistment.MountGVFS(); - - string majorVersion; - string minorVersion; - GVFSHelpers.GetPersistedDiskLayoutVersion(enlistment.DotGVFSRoot, out majorVersion, out minorVersion); - - majorVersion - .ShouldBeAnInt("Disk layout version should always be an int") - .ShouldEqual(WindowsDiskLayoutUpgradeTests.CurrentDiskLayoutMajorVersion, "Disk layout version should be upgraded to the latest"); - - minorVersion - .ShouldBeAnInt("Disk layout version should always be an int") - .ShouldEqual(WindowsDiskLayoutUpgradeTests.CurrentDiskLayoutMinorVersion, "Disk layout version should be upgraded to the latest"); - - string newBlobSizesRoot = Path.Combine(Path.GetDirectoryName(gitObjectsRoot), WindowsDiskLayoutUpgradeTests.BlobSizesCacheName); - GVFSHelpers.GetPersistedBlobSizesRoot(enlistment.DotGVFSRoot) - .ShouldEqual(newBlobSizesRoot); - - string blobSizesDbPath = Path.Combine(newBlobSizesRoot, WindowsDiskLayoutUpgradeTests.BlobSizesDBFileName); - newBlobSizesRoot.ShouldBeADirectory(this.fileSystem); - blobSizesDbPath.ShouldBeAFile(this.fileSystem); - - foreach (KeyValuePair entry in entries) - { - GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value); - } - - // Upgrade a second repo, and make sure all sizes from both upgrades are in the shared database - - GVFSFunctionalTestEnlistment enlistment2 = this.CloneAndMountEnlistment(); - enlistment2.UnmountGVFS(); - - // Delete the existing repo metadata - versionJsonPath = Path.Combine(enlistment2.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - // Since there isn't a sparse-checkout file that is used anymore one needs to be added - // in order to test the old upgrades that might have needed it - string sparseCheckoutPath2 = Path.Combine(enlistment2.RepoRoot, TestConstants.DotGit.Info.SparseCheckoutPath); - this.fileSystem.WriteAllText(sparseCheckoutPath2, "/.gitattributes\r\n"); - - // "13.0" was the last version before blob sizes were moved out of Esent - metadataPath = Path.Combine(enlistment2.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - this.fileSystem.CreateEmptyFile(metadataPath); - GVFSHelpers.SaveDiskLayoutVersion(enlistment2.DotGVFSRoot, "13", "0"); - GVFSHelpers.SaveLocalCacheRoot(enlistment2.DotGVFSRoot, localCacheRoot); - GVFSHelpers.SaveGitObjectsRoot(enlistment2.DotGVFSRoot, gitObjectsRoot); - - // Create a legacy PersistedDictionary sizes database - List> additionalEntries = new List>() - { - new KeyValuePair(new string('4', 40), 16), - new KeyValuePair(new string('5', 40), 32), - new KeyValuePair(new string('6', 40), 64), - }; - - ESENTDatabase.CreateEsentBlobSizesDatabase(enlistment2.DotGVFSRoot, additionalEntries); - - enlistment2.MountGVFS(); - - foreach (KeyValuePair entry in entries) - { - GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value); - } - - foreach (KeyValuePair entry in additionalEntries) - { - GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value); - } - } - private GVFSFunctionalTestEnlistment CloneAndMountEnlistment(string branch = null) { return this.CreateNewEnlistment(this.localCachePath, branch); diff --git a/GVFS/GVFS.FunctionalTests/Windows/Tests/WindowsDiskLayoutUpgradeTests.cs b/GVFS/GVFS.FunctionalTests/Windows/Tests/WindowsDiskLayoutUpgradeTests.cs index 328652458..a790516b6 100644 --- a/GVFS/GVFS.FunctionalTests/Windows/Tests/WindowsDiskLayoutUpgradeTests.cs +++ b/GVFS/GVFS.FunctionalTests/Windows/Tests/WindowsDiskLayoutUpgradeTests.cs @@ -1,7 +1,6 @@ using GVFS.FunctionalTests.Should; using GVFS.FunctionalTests.Tests.EnlistmentPerTestCase; using GVFS.FunctionalTests.Tools; -using GVFS.FunctionalTests.Windows.Tools; using GVFS.Tests.Should; using NUnit.Framework; using System; @@ -38,106 +37,15 @@ public override void CreateEnlistment() } [TestCase] - public void MountUpgradesFromVersion7() - { - // Seven to eight is a just a version change (non-breaking), but preserves ESENT RepoMetadata - this.RunEsentRepoMetadataUpgradeTest("7"); - } - - [TestCase] - public void MountUpgradesFromEsentToJsonRepoMetadata() - { - // Eight is the last version with ESENT RepoMetadata DB - this.RunEsentRepoMetadataUpgradeTest("8"); - } - - [TestCase] - public void MountUpgradesFromEsentDatabasesToFlatDatabases() - { - this.Enlistment.UnmountGVFS(); - - // Delete the existing background ops data - string flatBackgroundPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.BackgroundOpsFile); - flatBackgroundPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(flatBackgroundPath); - - // Delete the existing placeholder data - string placeholdersPath = Path.Combine(this.Enlistment.DotGVFSRoot, TestConstants.Databases.VFSForGit); - placeholdersPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(placeholdersPath); - - ESENTDatabase.CreateEsentBackgroundOpsDatabase(this.Enlistment.DotGVFSRoot); - ESENTDatabase.CreateEsentPlaceholderDatabase(this.Enlistment.DotGVFSRoot); - - // Nine is the last version with ESENT BackgroundOps and Placeholders DBs - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "9", "0"); - this.Enlistment.MountGVFS(); - - this.ValidatePersistedVersionMatchesCurrentVersion(); - - flatBackgroundPath.ShouldBeAFile(this.fileSystem); - placeholdersPath.ShouldBeAFile(this.fileSystem); - } - - [TestCase] - public void MountUpgradesFromPriorToPlaceholderCreationsBlockedForGit() - { - this.Enlistment.UnmountGVFS(); - - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "10", "0"); - - this.Enlistment.MountGVFS(); - - this.ValidatePersistedVersionMatchesCurrentVersion(); - } - - [TestCase] - public void MountFailsToUpgradeFromEsentVersion6ToJsonRepoMetadata() - { - this.Enlistment.UnmountGVFS(); - - // Delete the existing repo metadata - string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - ESENTDatabase.SaveDiskLayoutVersionAsEsentDatabase(this.Enlistment.DotGVFSRoot, "6"); - string esentDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, ESENTDatabase.EsentRepoMetadataFolder); - esentDatabasePath.ShouldBeADirectory(this.fileSystem); - - this.Enlistment.TryMountGVFS().ShouldEqual(false, "Should not be able to upgrade from version 6"); - - esentDatabasePath.ShouldBeADirectory(this.fileSystem); - } - - [TestCase] - public void MountSetsGitObjectsRootToLegacyDotGVFSCache() + public void MountUpgradesFromMinimumSupportedVersion() { this.Enlistment.UnmountGVFS(); - // Delete the existing repo metadata - string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - // "11" was the last version before the introduction of a volume wide GVFS cache - string metadataPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - this.fileSystem.CreateEmptyFile(metadataPath); - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "11", "0"); - - // Create the legacy cache location: \.gvfs\gitObjectCache - string legacyGitObjectsCachePath = Path.Combine(this.Enlistment.DotGVFSRoot, "gitObjectCache"); - this.fileSystem.CreateDirectory(legacyGitObjectsCachePath); + GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "14", "0"); this.Enlistment.MountGVFS(); this.ValidatePersistedVersionMatchesCurrentVersion(); - - GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12"); - - GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(legacyGitObjectsCachePath); } [TestCase] @@ -159,7 +67,7 @@ public void MountWritesFolderPlaceholdersToPlaceholderDatabase() placeholderDatabasePath, string.Join(Environment.NewLine, lines.Where(x => !x.EndsWith(TestConstants.PartialFolderPlaceholderDatabaseValue))) + Environment.NewLine); - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "12", "1"); + GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "15", "0"); this.Enlistment.MountGVFS(); this.Enlistment.UnmountGVFS(); @@ -200,65 +108,11 @@ public void MountUpdatesAllZeroShaFolderPlaceholderEntriesToPartialFolderSpecial this.ValidatePersistedVersionMatchesCurrentVersion(); } - [TestCase] - public void MountUpgradesPreSharedCacheLocalSizes() - { - this.Enlistment.UnmountGVFS(); - - // Delete the existing repo metadata - string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - // "11" was the last version before the introduction of a volume wide GVFS cache - string metadataPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - this.fileSystem.CreateEmptyFile(metadataPath); - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "11", "0"); - - // Create the legacy cache location: \.gvfs\gitObjectCache - string legacyGitObjectsCachePath = Path.Combine(this.Enlistment.DotGVFSRoot, "gitObjectCache"); - this.fileSystem.CreateDirectory(legacyGitObjectsCachePath); - - // Create a legacy PersistedDictionary sizes database - List> entries = new List>() - { - new KeyValuePair(new string('0', 40), 1), - new KeyValuePair(new string('1', 40), 2), - new KeyValuePair(new string('2', 40), 4), - new KeyValuePair(new string('3', 40), 8), - }; - - ESENTDatabase.CreateEsentBlobSizesDatabase(this.Enlistment.DotGVFSRoot, entries); - - this.Enlistment.MountGVFS(); - - this.ValidatePersistedVersionMatchesCurrentVersion(); - - GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12"); - - GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(legacyGitObjectsCachePath); - - string newBlobSizesRoot = Path.Combine(this.Enlistment.DotGVFSRoot, DatabasesFolderName, BlobSizesCacheName); - GVFSHelpers.GetPersistedBlobSizesRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(newBlobSizesRoot); - - string blobSizesDbPath = Path.Combine(newBlobSizesRoot, BlobSizesDBFileName); - newBlobSizesRoot.ShouldBeADirectory(this.fileSystem); - blobSizesDbPath.ShouldBeAFile(this.fileSystem); - - foreach (KeyValuePair entry in entries) - { - GVFSHelpers.SQLiteBlobSizesDatabaseHasEntry(blobSizesDbPath, entry.Key, entry.Value); - } - } - [TestCase] public void MountCreatesModifiedPathsDatabase() { this.Enlistment.UnmountGVFS(); - GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "14", "0"); + GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "15", "0"); // Delete the existing modified paths database to make sure mount creates it. string modifiedPathsDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, TestConstants.Databases.ModifiedPaths); @@ -376,37 +230,5 @@ private string[] GetPlaceholderDatabaseLinesAfterUpgradeFrom16(string placeholde lines.ShouldContain(x => x == this.PartialFolderPlaceholderString("GVFS", "GVFS.Tests", "Properties")); return lines; } - - private void RunEsentRepoMetadataUpgradeTest(string sourceVersion) - { - this.Enlistment.UnmountGVFS(); - - // Delete the existing repo metadata - string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); - versionJsonPath.ShouldBeAFile(this.fileSystem); - this.fileSystem.DeleteFile(versionJsonPath); - - ESENTDatabase.SaveDiskLayoutVersionAsEsentDatabase(this.Enlistment.DotGVFSRoot, sourceVersion); - string esentDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, ESENTDatabase.EsentRepoMetadataFolder); - esentDatabasePath.ShouldBeADirectory(this.fileSystem); - - // We should be able to mount, and there should no longer be any Esent Repo Metadata - this.Enlistment.MountGVFS(); - esentDatabasePath.ShouldNotExistOnDisk(this.fileSystem); - versionJsonPath.ShouldBeAFile(this.fileSystem); - - this.ValidatePersistedVersionMatchesCurrentVersion(); - - GVFSHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGVFSRoot) - .ShouldEqual(string.Empty, "LocalCacheRoot should be an empty string when upgrading from a version prior to 12"); - - // We're starting with fresh enlisments, and so the legacy cache location: \.gvfs\gitObjectCache should not be on disk - Path.Combine(this.Enlistment.DotGVFSRoot, ".gvfs", "gitObjectCache").ShouldNotExistOnDisk(this.fileSystem); - - // The upgrader should set GitObjectsRoot to src\.git\objects (because the legacy cache location is not on disk) - GVFSHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGVFSRoot) - .ShouldNotBeNull("GitObjectsRoot should not be null") - .ShouldEqual(Path.Combine(this.Enlistment.RepoRoot, ".git", "objects")); - } } } diff --git a/GVFS/GVFS.FunctionalTests/Windows/Tools/ESENTDatabase.cs b/GVFS/GVFS.FunctionalTests/Windows/Tools/ESENTDatabase.cs deleted file mode 100644 index 31c04e0b5..000000000 --- a/GVFS/GVFS.FunctionalTests/Windows/Tools/ESENTDatabase.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using Microsoft.Isam.Esent.Collections.Generic; - -namespace GVFS.FunctionalTests.Windows.Tools -{ - public static class ESENTDatabase - { - public const string EsentRepoMetadataFolder = "RepoMetadata"; - public const string EsentBackgroundOpsFolder = "BackgroundGitUpdates"; - public const string EsentBlobSizesFolder = "BlobSizes"; - public const string EsentPlaceholderFolder = "PlaceholderList"; - - private const string DiskLayoutMajorVersionKey = "DiskLayoutVersion"; - - public static void SaveDiskLayoutVersionAsEsentDatabase(string dotGVFSRoot, string majorVersion) - { - string metadataPath = Path.Combine(dotGVFSRoot, EsentRepoMetadataFolder); - using (PersistentDictionary repoMetadata = new PersistentDictionary(metadataPath)) - { - repoMetadata[DiskLayoutMajorVersionKey] = majorVersion; - repoMetadata.Flush(); - } - } - - public static void CreateEsentPlaceholderDatabase(string dotGVFSRoot) - { - string metadataPath = Path.Combine(dotGVFSRoot, EsentPlaceholderFolder); - using (PersistentDictionary placeholders = new PersistentDictionary(metadataPath)) - { - placeholders["mock:\\path"] = new string('0', 40); - placeholders.Flush(); - } - } - - public static void CreateEsentBackgroundOpsDatabase(string dotGVFSRoot) - { - // Copies an ESENT DB with a single entry: - // Operation=6 (OnFirstWrite) Path=.gitattributes VirtualPath=.gitattributes Id=1 - string testDataPath = GetTestDataPath(EsentBackgroundOpsFolder); - string metadataPath = Path.Combine(dotGVFSRoot, EsentBackgroundOpsFolder); - Directory.CreateDirectory(metadataPath); - foreach (string filepath in Directory.EnumerateFiles(testDataPath)) - { - string filename = Path.GetFileName(filepath); - File.Copy(filepath, Path.Combine(metadataPath, filename)); - } - } - - public static void CreateEsentBlobSizesDatabase(string dotGVFSRoot, List> entries) - { - string metadataPath = Path.Combine(dotGVFSRoot, EsentBlobSizesFolder); - using (PersistentDictionary blobSizes = new PersistentDictionary(metadataPath)) - { - foreach (KeyValuePair entry in entries) - { - blobSizes[entry.Key] = entry.Value; - } - - blobSizes.Flush(); - } - } - - private static string GetTestDataPath(string fileName) - { - string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - return Path.Combine(workingDirectory, "Windows", "TestData", fileName); - } - } -} diff --git a/GVFS/GVFS.GVFlt/GVFS.GVFlt.csproj b/GVFS/GVFS.GVFlt/GVFS.GVFlt.csproj deleted file mode 100644 index 44acd016c..000000000 --- a/GVFS/GVFS.GVFlt/GVFS.GVFlt.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - net471 - - - - - - - diff --git a/GVFS/GVFS.GVFlt/GVFltCallbacks.cs b/GVFS/GVFS.GVFlt/GVFltCallbacks.cs deleted file mode 100644 index f841f12ec..000000000 --- a/GVFS/GVFS.GVFlt/GVFltCallbacks.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Newtonsoft.Json; -using System; - -namespace GVFS.GVFlt -{ - public class GVFltCallbacks - { - /// - /// This struct must remain here for DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased - /// - /// - /// This struct should only be used by the upgrader, it has been replaced by GVFS.Virtualization.Background.FileSystemTask - /// - [Serializable] - public struct BackgroundGitUpdate - { - // This enum must be present or the BinarySerializer will always deserialze Operation as 0 - public enum OperationType - { - Invalid = 0, - } - - public OperationType Operation { get; set; } - public string VirtualPath { get; set; } - public string OldVirtualPath { get; set; } - - // Used by the logging in the upgrader - public override string ToString() - { - return JsonConvert.SerializeObject(this); - } - } - } -} diff --git a/GVFS/GVFS.Payload/GVFS.Payload.csproj b/GVFS/GVFS.Payload/GVFS.Payload.csproj index e7bc79415..49fe4a551 100644 --- a/GVFS/GVFS.Payload/GVFS.Payload.csproj +++ b/GVFS/GVFS.Payload/GVFS.Payload.csproj @@ -41,7 +41,6 @@ $(OutputPath)\GitHooksLoader.exe; $(OutputPath)\GVFS.Common.dll; $(OutputPath)\GVFS.exe; - $(OutputPath)\GVFS.GVFlt.dll; $(OutputPath)\GVFS.Hooks.exe; $(OutputPath)\GVFS.Mount.exe; $(OutputPath)\GVFS.Platform.Windows.dll; diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout10to11Upgrade_NewOperationType.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout10to11Upgrade_NewOperationType.cs deleted file mode 100644 index aa574ea8c..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout10to11Upgrade_NewOperationType.cs +++ /dev/null @@ -1,27 +0,0 @@ -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout10to11Upgrade_NewOperationType : DiskLayoutUpgrade.MajorUpgrade - { - protected override int SourceMajorVersion - { - get { return 10; } - } - - /// - /// Version 10 to 11 only added a new value to BackgroundGitUpdate.OperationType, - /// so we only need to bump the disk layout version version here. - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - } -} diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout11to12Upgrade_SharedLocalCache.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout11to12Upgrade_SharedLocalCache.cs deleted file mode 100644 index d5f31218f..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout11to12Upgrade_SharedLocalCache.cs +++ /dev/null @@ -1,63 +0,0 @@ -using GVFS.Common; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using System.IO; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout11to12Upgrade_SharedLocalCache : DiskLayoutUpgrade.MajorUpgrade - { - protected override int SourceMajorVersion - { - get { return 11; } - } - - /// - /// Version 11 to 12 added the shared local git objects cache. - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSPath = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - string error; - if (!RepoMetadata.TryInitialize(tracer, dotGVFSPath, out error)) - { - tracer.RelatedError(nameof(this.TryUpgradeGitObjectPath) + ": Could not initialize repo metadata: " + error); - return false; - } - - if (!this.TryUpgradeGitObjectPath(tracer, enlistmentRoot)) - { - return false; - } - - RepoMetadata.Instance.SetLocalCacheRoot(string.Empty); - tracer.RelatedInfo("Set LocalCacheRoot to string.Empty"); - - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - - private bool TryUpgradeGitObjectPath(ITracer tracer, string enlistmentRoot) - { - string gitObjectsRoot; - string legacyDotGVFSGitObjectCachePath = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot, "gitObjectCache"); - if (Directory.Exists(legacyDotGVFSGitObjectCachePath)) - { - gitObjectsRoot = legacyDotGVFSGitObjectCachePath; - } - else - { - // Old version prior to \.gvfs\gitObjectCache cache - gitObjectsRoot = Path.Combine(enlistmentRoot, GVFSConstants.WorkingDirectoryRootName, GVFSConstants.DotGit.Objects.Root); - } - - RepoMetadata.Instance.SetGitObjectsRoot(gitObjectsRoot); - tracer.RelatedInfo("Set GitObjectsRoot: " + gitObjectsRoot); - return true; - } - } -} \ No newline at end of file diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12_0To12_1Upgrade_StatusAheadBehind.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12_0To12_1Upgrade_StatusAheadBehind.cs deleted file mode 100644 index 2f90d8a43..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12_0To12_1Upgrade_StatusAheadBehind.cs +++ /dev/null @@ -1,35 +0,0 @@ -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using System.Collections.Generic; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout12_0To12_1Upgrade_StatusAheadBehind : DiskLayoutUpgrade.MinorUpgrade - { - protected override int SourceMajorVersion - { - get { return 12; } - } - - protected override int SourceMinorVersion - { - get { return 0; } - } - - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - if (!this.TrySetGitConfig( - tracer, - enlistmentRoot, - new Dictionary - { - { "status.aheadbehind", "false" }, - })) - { - return false; - } - - return this.TryIncrementMinorVersion(tracer, enlistmentRoot); - } - } -} diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12to13Upgrade_FolderPlaceholder.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12to13Upgrade_FolderPlaceholder.cs deleted file mode 100644 index 496363404..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout12to13Upgrade_FolderPlaceholder.cs +++ /dev/null @@ -1,123 +0,0 @@ -using GVFS.Common; -using GVFS.Common.Database; -using GVFS.Common.FileSystem; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using Microsoft.Windows.ProjFS; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout12to13Upgrade_FolderPlaceholder : DiskLayoutUpgrade.MajorUpgrade - { - protected override int SourceMajorVersion - { - get { return 12; } - } - - /// - /// Adds the folder placeholders to the placeholders list - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSRoot = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - try - { - string error; - LegacyPlaceholderListDatabase placeholders; - if (!LegacyPlaceholderListDatabase.TryCreate( - tracer, - Path.Combine(dotGVFSRoot, GVFSConstants.DotGVFS.Databases.PlaceholderList), - new PhysicalFileSystem(), - out placeholders, - out error)) - { - tracer.RelatedError("Failed to open placeholder database: " + error); - return false; - } - - using (placeholders) - { - string workingDirectoryRoot = Path.Combine(enlistmentRoot, GVFSConstants.WorkingDirectoryRootName); - - // Run through the folder placeholders adding to the placeholder list - IEnumerable folderPlaceholderPaths = - GetFolderPlaceholdersFromDisk(tracer, new PhysicalFileSystem(), workingDirectoryRoot) - .Select(x => x.Substring(workingDirectoryRoot.Length + 1)) - .Select(x => new LegacyPlaceholderListDatabase.PlaceholderData(x, GVFSConstants.AllZeroSha)); - - List placeholderEntries = placeholders.GetAllEntries(); - placeholderEntries.AddRange(folderPlaceholderPaths); - - placeholders.WriteAllEntriesAndFlush(placeholderEntries); - } - } - catch (IOException ex) - { - tracer.RelatedError("Could not write to placeholder database: " + ex.ToString()); - return false; - } - catch (Exception ex) - { - tracer.RelatedError("Error updating placeholder database with folders: " + ex.ToString()); - return false; - } - - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - - private static IEnumerable GetFolderPlaceholdersFromDisk(ITracer tracer, PhysicalFileSystem fileSystem, string path) - { - if (!fileSystem.IsSymLink(path)) - { - foreach (string directory in fileSystem.EnumerateDirectories(path)) - { - if (!directory.EndsWith(Path.DirectorySeparatorChar + GVFSConstants.DotGit.Root)) - { - OnDiskFileState fileState = OnDiskFileState.Full; - if (Utils.TryGetOnDiskFileState(directory, out fileState)) - { - if (IsPlaceholder(fileState)) - { - yield return directory; - } - - // Recurse into placeholders and full folders skipping the tombstones - if (!IsTombstone(fileState)) - { - foreach (string placeholderPath in GetFolderPlaceholdersFromDisk(tracer, fileSystem, directory)) - { - yield return placeholderPath; - } - } - } - else - { - // May cause valid folder placeholders not to be written - // to the placeholder database so we want to error out. - throw new InvalidDataException($"Error getting on disk file state for {directory}"); - } - } - } - } - } - - private static bool IsTombstone(OnDiskFileState fileState) - { - return (fileState & OnDiskFileState.Tombstone) != 0; - } - - private static bool IsPlaceholder(OnDiskFileState fileState) - { - return (fileState & (OnDiskFileState.DirtyPlaceholder | OnDiskFileState.HydratedPlaceholder | OnDiskFileState.Placeholder)) != 0; - } - } -} diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout13to14Upgrade_BlobSizes.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout13to14Upgrade_BlobSizes.cs deleted file mode 100644 index f784bcc87..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout13to14Upgrade_BlobSizes.cs +++ /dev/null @@ -1,139 +0,0 @@ -using GVFS.Common; -using GVFS.Common.FileSystem; -using GVFS.Common.Git; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using GVFS.Virtualization.BlobSize; -using Microsoft.Isam.Esent; -using Microsoft.Isam.Esent.Collections.Generic; -using System.Collections.Generic; -using System.IO; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout13to14Upgrade_BlobSizes : DiskLayoutUpgrade.MajorUpgrade - { - private static readonly string BlobSizesName = "BlobSizes"; - - protected override int SourceMajorVersion - { - get { return 13; } - } - - /// - /// Version 13 to 14 added the (shared) SQLite blob sizes database - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSPath = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - string error; - if (!RepoMetadata.TryInitialize(tracer, dotGVFSPath, out error)) - { - tracer.RelatedError($"{nameof(DiskLayout13to14Upgrade_BlobSizes)}.{nameof(this.TryUpgrade)}: Could not initialize repo metadata: {error}"); - return false; - } - - string newBlobSizesRoot; - if (!this.TryFindNewBlobSizesRoot(tracer, enlistmentRoot, out newBlobSizesRoot)) - { - return false; - } - - this.MigrateBlobSizes(tracer, enlistmentRoot, newBlobSizesRoot); - - RepoMetadata.Instance.SetBlobSizesRoot(newBlobSizesRoot); - tracer.RelatedInfo("Set BlobSizesRoot: " + newBlobSizesRoot); - - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - - private bool TryFindNewBlobSizesRoot(ITracer tracer, string enlistmentRoot, out string newBlobSizesRoot) - { - newBlobSizesRoot = null; - - string localCacheRoot; - string error; - if (!RepoMetadata.Instance.TryGetLocalCacheRoot(out localCacheRoot, out error)) - { - tracer.RelatedError($"{nameof(DiskLayout13to14Upgrade_BlobSizes)}.{nameof(this.TryFindNewBlobSizesRoot)}: Could not read local cache root from repo metadata: {error}"); - return false; - } - - if (localCacheRoot == string.Empty) - { - // This is an old repo that was cloned prior to the shared cache - // Blob sizes root should be \.gvfs\databases\blobSizes - newBlobSizesRoot = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.Name, GVFSEnlistment.BlobSizesCacheName); - } - else - { - // This repo was cloned with a shared cache, and the blob sizes should be a sibling to the git objects root - string gitObjectsRoot; - if (!RepoMetadata.Instance.TryGetGitObjectsRoot(out gitObjectsRoot, out error)) - { - tracer.RelatedError($"{nameof(DiskLayout13to14Upgrade_BlobSizes)}.{nameof(this.TryFindNewBlobSizesRoot)}: Could not read git object root from repo metadata: {error}"); - return false; - } - - string cacheRepoFolder = Path.GetDirectoryName(gitObjectsRoot); - newBlobSizesRoot = Path.Combine(cacheRepoFolder, GVFSEnlistment.BlobSizesCacheName); - } - - return true; - } - - private void MigrateBlobSizes(ITracer tracer, string enlistmentRoot, string newBlobSizesRoot) - { - string esentBlobSizeFolder = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot, BlobSizesName); - PhysicalFileSystem fileSystem = new PhysicalFileSystem(); - if (!fileSystem.DirectoryExists(esentBlobSizeFolder)) - { - tracer.RelatedInfo("Copied no ESENT blob size entries. {0} does not exist", esentBlobSizeFolder); - return; - } - - try - { - using (PersistentDictionary oldBlobSizes = new PersistentDictionary(esentBlobSizeFolder)) - using (BlobSizes newBlobSizes = new BlobSizes(newBlobSizesRoot, fileSystem, tracer)) - { - newBlobSizes.Initialize(); - - int copiedCount = 0; - int totalCount = oldBlobSizes.Count; - foreach (KeyValuePair kvp in oldBlobSizes) - { - Sha1Id sha1; - string error; - if (Sha1Id.TryParse(kvp.Key, out sha1, out error)) - { - newBlobSizes.AddSize(sha1, kvp.Value); - - if (copiedCount++ % 5000 == 0) - { - tracer.RelatedInfo("Copied {0}/{1} ESENT blob size entries", copiedCount, totalCount); - } - } - else - { - tracer.RelatedWarning($"Corrupt entry ({kvp.Key}) found in BlobSizes, skipping. Error: {error}"); - } - } - - newBlobSizes.Flush(); - newBlobSizes.Shutdown(); - tracer.RelatedInfo("Upgrade complete: Copied {0}/{1} ESENT blob size entries", copiedCount, totalCount); - } - } - catch (EsentException ex) - { - tracer.RelatedWarning("BlobSizes appears to be from an older version of GVFS and corrupted, skipping upgrade of blob sizes: " + ex.Message); - } - } - } -} diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout7to8Upgrade_NewOperationType.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout7to8Upgrade_NewOperationType.cs deleted file mode 100644 index d4edabd4e..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout7to8Upgrade_NewOperationType.cs +++ /dev/null @@ -1,42 +0,0 @@ -using GVFS.Common; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using Microsoft.Isam.Esent; -using Microsoft.Isam.Esent.Collections.Generic; -using System.IO; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout7to8Upgrade_NewOperationType : DiskLayoutUpgrade.MajorUpgrade - { - protected override int SourceMajorVersion - { - get { return 7; } - } - - /// - /// Version 7 to 8 only added a new value to BackgroundGitUpdate.OperationType, - /// so we only need to bump the ESENT version here. - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSRoot = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - string esentRepoMetadata = Path.Combine(dotGVFSRoot, WindowsDiskLayoutUpgradeData.EsentRepoMetadataName); - try - { - using (PersistentDictionary esentMetadata = new PersistentDictionary(esentRepoMetadata)) - { - esentMetadata[WindowsDiskLayoutUpgradeData.DiskLayoutEsentVersionKey] = "8"; - } - } - catch (EsentException ex) - { - tracer.RelatedError("RepoMetadata appears to be from an older version of GVFS and corrupted: " + ex.Message); - return false; - } - - // Do not call TryIncrementDiskLayoutVersion. It updates the flat repo metadata which does not exist yet. - return true; - } - } -} \ No newline at end of file diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout8to9Upgrade_RepoMetadataToJson.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout8to9Upgrade_RepoMetadataToJson.cs deleted file mode 100644 index b86fab6b9..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout8to9Upgrade_RepoMetadataToJson.cs +++ /dev/null @@ -1,89 +0,0 @@ -using GVFS.Common; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using Microsoft.Isam.Esent; -using Microsoft.Isam.Esent.Collections.Generic; -using System.Collections.Generic; -using System.IO; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout8to9Upgrade_RepoMetadataToJson : DiskLayoutUpgrade.MajorUpgrade - { - protected override int SourceMajorVersion - { - get { return 8; } - } - - /// - /// Rewrites ESENT RepoMetadata DB to flat JSON file - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSRoot = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - if (!this.UpdateRepoMetadata(tracer, dotGVFSRoot)) - { - return false; - } - - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - - private bool UpdateRepoMetadata(ITracer tracer, string dotGVFSRoot) - { - string esentRepoMetadata = Path.Combine(dotGVFSRoot, WindowsDiskLayoutUpgradeData.EsentRepoMetadataName); - if (Directory.Exists(esentRepoMetadata)) - { - try - { - using (PersistentDictionary oldMetadata = new PersistentDictionary(esentRepoMetadata)) - { - string error; - if (!RepoMetadata.TryInitialize(tracer, dotGVFSRoot, out error)) - { - tracer.RelatedError("Could not initialize RepoMetadata: " + error); - return false; - } - - foreach (KeyValuePair kvp in oldMetadata) - { - tracer.RelatedInfo("Copying ESENT entry: {0} = {1}", kvp.Key, kvp.Value); - RepoMetadata.Instance.SetEntry(kvp.Key, kvp.Value); - } - } - } - catch (IOException ex) - { - tracer.RelatedError("Could not write to new repo metadata: " + ex.Message); - return false; - } - catch (EsentException ex) - { - tracer.RelatedError("RepoMetadata appears to be from an older version of GVFS and corrupted: " + ex.Message); - return false; - } - - string backupName; - if (this.TryRenameFolderForDelete(tracer, esentRepoMetadata, out backupName)) - { - // If this fails, we leave behind cruft, but there's no harm because we renamed. - this.TryDeleteFolder(tracer, backupName); - return true; - } - else - { - // To avoid double upgrading, we should rollback if we can't rename the old data - this.TryDeleteFile(tracer, RepoMetadata.Instance.DataFilePath); - return false; - } - } - - return true; - } - } -} \ No newline at end of file diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased.cs deleted file mode 100644 index 9b0b84b12..000000000 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased.cs +++ /dev/null @@ -1,181 +0,0 @@ -using GVFS.Common; -using GVFS.Common.FileSystem; -using GVFS.Common.Tracing; -using GVFS.DiskLayoutUpgrades; -using GVFS.GVFlt; -using GVFS.Virtualization.Background; -using Microsoft.Isam.Esent; -using Microsoft.Isam.Esent.Collections.Generic; -using System.Collections.Generic; -using System.IO; - -namespace GVFS.Platform.Windows.DiskLayoutUpgrades -{ - public class DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased : DiskLayoutUpgrade.MajorUpgrade - { - private const string EsentBackgroundOpsFolder = "BackgroundGitUpdates"; - private const string EsentPlaceholderListFolder = "PlaceholderList"; - - protected override int SourceMajorVersion - { - get { return 9; } - } - - /// - /// Rewrites ESENT BackgroundGitUpdates and PlaceholderList DBs to flat formats - /// - public override bool TryUpgrade(ITracer tracer, string enlistmentRoot) - { - string dotGVFSRoot = Path.Combine(enlistmentRoot, GVFSPlatform.Instance.Constants.DotGVFSRoot); - if (!this.UpdateBackgroundOperations(tracer, dotGVFSRoot)) - { - return false; - } - - if (!this.UpdatePlaceholderList(tracer, dotGVFSRoot)) - { - return false; - } - - if (!this.TryIncrementMajorVersion(tracer, enlistmentRoot)) - { - return false; - } - - return true; - } - - private bool UpdatePlaceholderList(ITracer tracer, string dotGVFSRoot) - { - string esentPlaceholderFolder = Path.Combine(dotGVFSRoot, EsentPlaceholderListFolder); - if (Directory.Exists(esentPlaceholderFolder)) - { - string newPlaceholderFolder = Path.Combine(dotGVFSRoot, GVFSConstants.DotGVFS.Databases.PlaceholderList); - try - { - using (PersistentDictionary oldPlaceholders = - new PersistentDictionary(esentPlaceholderFolder)) - { - string error; - LegacyPlaceholderListDatabase newPlaceholders; - if (!LegacyPlaceholderListDatabase.TryCreate( - tracer, - newPlaceholderFolder, - new PhysicalFileSystem(), - out newPlaceholders, - out error)) - { - tracer.RelatedError("Failed to create new placeholder database: " + error); - return false; - } - - using (newPlaceholders) - { - List data = new List(); - foreach (KeyValuePair kvp in oldPlaceholders) - { - tracer.RelatedInfo("Copying ESENT entry: {0} = {1}", kvp.Key, kvp.Value); - data.Add(new LegacyPlaceholderListDatabase.PlaceholderData(path: kvp.Key, fileShaOrFolderValue: kvp.Value)); - } - - newPlaceholders.WriteAllEntriesAndFlush(data); - } - } - } - catch (IOException ex) - { - tracer.RelatedError("Could not write to new placeholder database: " + ex.Message); - return false; - } - catch (EsentException ex) - { - tracer.RelatedError("Placeholder database appears to be from an older version of GVFS and corrupted: " + ex.Message); - return false; - } - - string backupName; - if (this.TryRenameFolderForDelete(tracer, esentPlaceholderFolder, out backupName)) - { - // If this fails, we leave behind cruft, but there's no harm because we renamed. - this.TryDeleteFolder(tracer, backupName); - return true; - } - else - { - // To avoid double upgrading, we should rollback if we can't rename the old data - this.TryDeleteFile(tracer, RepoMetadata.Instance.DataFilePath); - return false; - } - } - - return true; - } - - private bool UpdateBackgroundOperations(ITracer tracer, string dotGVFSRoot) - { - string esentBackgroundOpsFolder = Path.Combine(dotGVFSRoot, EsentBackgroundOpsFolder); - if (Directory.Exists(esentBackgroundOpsFolder)) - { - string newBackgroundOpsFolder = Path.Combine(dotGVFSRoot, GVFSConstants.DotGVFS.Databases.BackgroundFileSystemTasks); - try - { - using (PersistentDictionary oldBackgroundOps = - new PersistentDictionary(esentBackgroundOpsFolder)) - { - string error; - FileSystemTaskQueue newBackgroundOps; - if (!FileSystemTaskQueue.TryCreate( - tracer, - newBackgroundOpsFolder, - new PhysicalFileSystem(), - out newBackgroundOps, - out error)) - { - tracer.RelatedError("Failed to create new background operations folder: " + error); - return false; - } - - using (newBackgroundOps) - { - foreach (KeyValuePair kvp in oldBackgroundOps) - { - tracer.RelatedInfo("Copying ESENT entry: {0} = {1}", kvp.Key, kvp.Value); - newBackgroundOps.EnqueueAndFlush( - new FileSystemTask( - (FileSystemTask.OperationType)kvp.Value.Operation, - kvp.Value.VirtualPath, - kvp.Value.OldVirtualPath)); - } - } - } - } - catch (IOException ex) - { - tracer.RelatedError("Could not write to new background operations: " + ex.Message); - return false; - } - catch (EsentException ex) - { - tracer.RelatedError("BackgroundOperations appears to be from an older version of GVFS and corrupted: " + ex.Message); - return false; - } - - string backupName; - if (this.TryRenameFolderForDelete(tracer, esentBackgroundOpsFolder, out backupName)) - { - // If this fails, we leave behind cruft, but there's no harm because we renamed. - this.TryDeleteFolder(tracer, backupName); - return true; - } - else - { - // To avoid double upgrading, we should rollback if we can't rename the old data - this.TryDeleteFile(tracer, RepoMetadata.Instance.DataFilePath); - return false; - } - } - - return true; - } - } -} diff --git a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/WindowsDiskLayoutUpgradeData.cs b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/WindowsDiskLayoutUpgradeData.cs index d79e29594..6fdab6c91 100644 --- a/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/WindowsDiskLayoutUpgradeData.cs +++ b/GVFS/GVFS.Platform.Windows/DiskLayoutUpgrades/WindowsDiskLayoutUpgradeData.cs @@ -1,30 +1,16 @@ using GVFS.Common; using GVFS.DiskLayoutUpgrades; -using Microsoft.Isam.Esent.Collections.Generic; -using System; -using System.IO; namespace GVFS.Platform.Windows.DiskLayoutUpgrades { public class WindowsDiskLayoutUpgradeData : IDiskLayoutUpgradeData { - public const string DiskLayoutEsentVersionKey = "DiskLayoutVersion"; - public const string EsentRepoMetadataName = "RepoMetadata"; - public DiskLayoutUpgrade[] Upgrades { get { return new DiskLayoutUpgrade[] { - new DiskLayout7to8Upgrade_NewOperationType(), - new DiskLayout8to9Upgrade_RepoMetadataToJson(), - new DiskLayout9to10Upgrade_BackgroundAndPlaceholderListToFileBased(), - new DiskLayout10to11Upgrade_NewOperationType(), - new DiskLayout11to12Upgrade_SharedLocalCache(), - new DiskLayout12_0To12_1Upgrade_StatusAheadBehind(), - new DiskLayout12to13Upgrade_FolderPlaceholder(), - new DiskLayout13to14Upgrade_BlobSizes(), new DiskLayout14to15Upgrade_ModifiedPaths(), new DiskLayout15to16Upgrade_GitStatusCache(), new DiskLayout16to17Upgrade_FolderPlaceholderValues(), @@ -37,36 +23,12 @@ public DiskLayoutUpgrade[] Upgrades public DiskLayoutVersion Version => new DiskLayoutVersion( currentMajorVersion: 19, currentMinorVersion: 0, - minimumSupportedMajorVersion: 7); + minimumSupportedMajorVersion: 14); public bool TryParseLegacyDiskLayoutVersion(string dotGVFSPath, out int majorVersion) { - string repoMetadataPath = Path.Combine(dotGVFSPath, EsentRepoMetadataName); majorVersion = 0; - if (Directory.Exists(repoMetadataPath)) - { - try - { - using (PersistentDictionary oldMetadata = new PersistentDictionary(repoMetadataPath)) - { - string versionString = oldMetadata[DiskLayoutEsentVersionKey]; - if (!int.TryParse(versionString, out majorVersion)) - { - return false; - } - } - } - catch - { - return false; - } - } - else - { - return false; - } - - return true; + return false; } } } diff --git a/GVFS/GVFS.Platform.Windows/GVFS.Platform.Windows.csproj b/GVFS/GVFS.Platform.Windows/GVFS.Platform.Windows.csproj index 1bf325061..0ffe30b8f 100644 --- a/GVFS/GVFS.Platform.Windows/GVFS.Platform.Windows.csproj +++ b/GVFS/GVFS.Platform.Windows/GVFS.Platform.Windows.csproj @@ -5,14 +5,10 @@ - - - -