コード例 #1
0
        public static bool TryRunAllUpgrades(string enlistmentRoot)
        {
            majorVersionUpgrades = new Dictionary <int, MajorUpgrade>();
            minorVersionUpgrades = new Dictionary <int, Dictionary <int, MinorUpgrade> >();

            foreach (DiskLayoutUpgrade upgrade in GVFSPlatform.Instance.DiskLayoutUpgrade.Upgrades)
            {
                RegisterUpgrade(upgrade);
            }

            using (JsonTracer tracer = new JsonTracer(GVFSConstants.GVFSEtwProviderName, "DiskLayoutUpgrade"))
            {
                try
                {
                    DiskLayoutUpgrade upgrade = null;
                    while (TryFindUpgrade(tracer, enlistmentRoot, out upgrade))
                    {
                        if (upgrade == null)
                        {
                            return(true);
                        }

                        if (!upgrade.TryUpgrade(tracer, enlistmentRoot))
                        {
                            return(false);
                        }

                        if (!CheckLayoutVersionWasIncremented(tracer, enlistmentRoot, upgrade))
                        {
                            return(false);
                        }
                    }

                    return(false);
                }
                catch (Exception e)
                {
                    StartLogFile(enlistmentRoot, tracer);
                    tracer.RelatedError(e.ToString());
                    return(false);
                }
                finally
                {
                    RepoMetadata.Shutdown();
                }
            }
        }
コード例 #2
0
ファイル: DiskLayoutUpgrade.cs プロジェクト: yyqyu/GVFS
        public static bool TryRunAllUpgrades(string enlistmentRoot)
        {
            using (JsonEtwTracer tracer = new JsonEtwTracer(GVFSConstants.GVFSEtwProviderName, "DiskLayoutUpgrade"))
            {
                try
                {
                    DiskLayoutUpgrade upgrade = null;
                    while (TryFindUpgrade(tracer, enlistmentRoot, out upgrade))
                    {
                        if (upgrade == null)
                        {
                            return(true);
                        }

                        if (!upgrade.TryUpgrade(tracer, enlistmentRoot))
                        {
                            return(false);
                        }

                        if (!CheckLayoutVersionWasIncremented(tracer, enlistmentRoot, upgrade))
                        {
                            return(false);
                        }
                    }

                    return(false);
                }
                catch (Exception e)
                {
                    StartLogFile(enlistmentRoot, tracer);
                    tracer.RelatedError(e.ToString());
                    return(false);
                }
                finally
                {
                    RepoMetadata.Shutdown();
                }
            }
        }