Exemplo n.º 1
0
        private bool PerformPreMountValidation(ITracer tracer, GVFSEnlistment enlistment, out string mountExecutableLocation, out string errorMessage)
        {
            errorMessage            = string.Empty;
            mountExecutableLocation = string.Empty;

            // We have to parse these parameters here to make sure they are valid before
            // handing them to the background process which cannot tell the user when they are bad
            EventLevel verbosity;
            Keywords   keywords;

            this.ParseEnumArgs(out verbosity, out keywords);

            mountExecutableLocation = Path.Combine(ProcessHelper.GetCurrentProcessLocation(), GVFSPlatform.Instance.Constants.MountExecutableName);
            if (!File.Exists(mountExecutableLocation))
            {
                errorMessage = $"Could not find {GVFSPlatform.Instance.Constants.MountExecutableName}. You may need to reinstall GVFS.";
                return(false);
            }

            GitProcess git = new GitProcess(enlistment);

            if (!git.IsValidRepo())
            {
                errorMessage = "The .git folder is missing or has invalid contents";
                return(false);
            }

            try
            {
                GitIndexProjection.ReadIndex(tracer, Path.Combine(enlistment.WorkingDirectoryBackingRoot, GVFSConstants.DotGit.Index));
            }
            catch (Exception e)
            {
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Exception", e.ToString());
                tracer.RelatedError(metadata, "Index validation failed");
                errorMessage = "Index validation failed, run 'gvfs repair' to repair index.";

                return(false);
            }

            if (!GVFSPlatform.Instance.FileSystem.IsFileSystemSupported(enlistment.EnlistmentRoot, out string error))
            {
                errorMessage = $"FileSystem unsupported: {error}";
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            GVFSPlatformLoader.Initialize();
            string enlistmentRootPath = @"M:\OS";

            if (args.Length > 0 && !string.IsNullOrWhiteSpace(args[0]))
            {
                enlistmentRootPath = args[0];
            }

            TestsToRun testsToRun = TestsToRun.All;

            if (args.Length > 1)
            {
                int tests;
                if (int.TryParse(args[1], out tests))
                {
                    testsToRun = (TestsToRun)tests;
                }
            }

            ProfilingEnvironment environment = new ProfilingEnvironment(enlistmentRootPath);

            Dictionary <TestsToRun, Action> allTests = new Dictionary <TestsToRun, Action>
            {
                { TestsToRun.ValidateIndex, () => GitIndexProjection.ReadIndex(environment.Context.Tracer, Path.Combine(environment.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Index)) },
                { TestsToRun.RebuildProjection, () => environment.FileSystemCallbacks.GitIndexProjectionProfiler.ForceRebuildProjection() },
                { TestsToRun.ValidateModifiedPaths, () => environment.FileSystemCallbacks.GitIndexProjectionProfiler.ForceAddMissingModifiedPaths(environment.Context.Tracer) },
            };

            long before = GetMemoryUsage();

            foreach (KeyValuePair <TestsToRun, Action> test in allTests)
            {
                if (IsOn(testsToRun, test.Key))
                {
                    TimeIt(test.Key.ToString(), test.Value);
                }
            }

            long after = GetMemoryUsage();

            Console.WriteLine($"Memory Usage: {FormatByteCount(after - before)}");
            Console.WriteLine();
            Console.WriteLine("Press Enter to exit");
            Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ProfilingEnvironment environment = new ProfilingEnvironment(@"M:\OS");

            TimeIt(
                "Validate Index",
                () => GitIndexProjection.ReadIndex(Path.Combine(environment.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Index)));
            TimeIt(
                "Index Parse (new projection)",
                () => environment.GVFltCallbacks.GitIndexProjectionProfiler.ForceRebuildProjection());
            TimeIt(
                "Index Parse (update offsets and validate)",
                () => environment.GVFltCallbacks.GitIndexProjectionProfiler.ForceUpdateOffsetsAndValidateSparseCheckout());
            TimeIt(
                "Index Parse (validate sparse checkout)",
                () => environment.GVFltCallbacks.GitIndexProjectionProfiler.ForceValidateSparseCheckout());
            Console.WriteLine("Press Enter to exit");
        }