示例#1
0
        protected IssueType TryParseIndex(string path, List <string> messages)
        {
            GVFSContext context = new GVFSContext(this.Tracer, null, null, this.Enlistment);

            using (GitIndexProjection index = new GitIndexProjection(
                       context,
                       gitObjects: null,
                       blobSizes: null,
                       repoMetadata: null,
                       fileSystemVirtualizer: null,
                       placeholderDatabase: null,
                       modifiedPaths: null))
            {
                try
                {
                    index.BuildProjectionFromPath(this.Tracer, path);
                }
                catch (Exception ex)
                {
                    messages.Add("Failed to parse index at " + path);
                    this.Tracer.RelatedInfo(ex.ToString());
                    return(IssueType.Fixable);
                }
            }

            return(IssueType.None);
        }
 public MockFileSystemCallbacks(
     GVFSContext context,
     GVFSGitObjects gitObjects,
     RepoMetadata repoMetadata,
     BlobSizes blobSizes,
     GitIndexProjection gitIndexProjection,
     BackgroundFileSystemTaskRunner backgroundFileSystemTaskRunner,
     FileSystemVirtualizer fileSystemVirtualizer)
     : base(context, gitObjects, repoMetadata, blobSizes, gitIndexProjection, backgroundFileSystemTaskRunner, fileSystemVirtualizer)
 {
 }
 public MockFileSystemCallbacks(
     GVFSContext context,
     GVFSGitObjects gitObjects,
     RepoMetadata repoMetadata,
     BlobSizes blobSizes,
     GitIndexProjection gitIndexProjection,
     BackgroundFileSystemTaskRunner backgroundFileSystemTaskRunner,
     FileSystemVirtualizer fileSystemVirtualizer,
     IPlaceholderCollection placeholderDatabase,
     ISparseCollection sparseCollection)
     : base(context, gitObjects, repoMetadata, blobSizes, gitIndexProjection, backgroundFileSystemTaskRunner, fileSystemVirtualizer, placeholderDatabase, sparseCollection)
 {
 }
示例#4
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);
        }
示例#5
0
        public void LoadOrCreate(GitIndexProjection gitIndexProjection)
        {
            this.gitIndexProjection = gitIndexProjection;

            foreach (string line in this.sparseCheckoutSerializer.ReadAll())
            {
                string sanitizedFileLine;
                if (GitConfigHelper.TrySanitizeConfigFileLine(line, out sanitizedFileLine))
                {
                    this.sparseCheckoutEntries.Add(sanitizedFileLine);
                }
            }

            this.sparseCheckoutSerializer.Close();
        }
示例#6
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();
        }
示例#7
0
文件: Program.cs 项目: yyqyu/GVFS
        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");
        }
示例#8
0
        public void Dispose()
        {
            if (this.BlobSizes != null)
            {
                this.BlobSizes.Dispose();
                this.BlobSizes = null;
            }

            if (this.fileSystemVirtualizer != null)
            {
                this.fileSystemVirtualizer.Dispose();
                this.fileSystemVirtualizer = null;
            }

            if (this.GitIndexProjection != null)
            {
                this.GitIndexProjection.Dispose();
                this.GitIndexProjection = null;
            }

            if (this.modifiedPaths != null)
            {
                this.modifiedPaths.Dispose();
                this.modifiedPaths = null;
            }

            if (this.gitStatusCache != null)
            {
                this.gitStatusCache.Dispose();
                this.gitStatusCache = null;
            }

            if (this.backgroundFileSystemTaskRunner != null)
            {
                this.backgroundFileSystemTaskRunner.Dispose();
                this.backgroundFileSystemTaskRunner = null;
            }

            if (this.context != null)
            {
                this.context.Dispose();
                this.context = null;
            }
        }
 public GitIndexParser(GitIndexProjection projection)
 {
     this.projection = projection;
     this.page       = new byte[PageSize];
 }
示例#10
0
        public FileSystemCallbacks(
            GVFSContext context,
            GVFSGitObjects gitObjects,
            RepoMetadata repoMetadata,
            BlobSizes blobSizes,
            GitIndexProjection gitIndexProjection,
            BackgroundFileSystemTaskRunner backgroundFileSystemTaskRunner,
            FileSystemVirtualizer fileSystemVirtualizer,
            GitStatusCache gitStatusCache = null)
        {
            this.logsHeadFileProperties = null;
            this.postFetchJobLock       = new object();

            this.context               = context;
            this.gitObjects            = gitObjects;
            this.fileSystemVirtualizer = fileSystemVirtualizer;

            this.placeHolderCreationCount       = new ConcurrentDictionary <string, PlaceHolderCreateCounter>(StringComparer.OrdinalIgnoreCase);
            this.newlyCreatedFileAndFolderPaths = new ConcurrentHashSet <string>(StringComparer.OrdinalIgnoreCase);

            string error;

            if (!ModifiedPathsDatabase.TryLoadOrCreate(
                    this.context.Tracer,
                    Path.Combine(this.context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.ModifiedPaths),
                    this.context.FileSystem,
                    out this.modifiedPaths,
                    out error))
            {
                throw new InvalidRepoException(error);
            }

            this.BlobSizes = blobSizes;
            this.BlobSizes.Initialize();

            PlaceholderListDatabase placeholders;

            if (!PlaceholderListDatabase.TryCreate(
                    this.context.Tracer,
                    Path.Combine(this.context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.PlaceholderList),
                    this.context.FileSystem,
                    out placeholders,
                    out error))
            {
                throw new InvalidRepoException(error);
            }

            this.GitIndexProjection = gitIndexProjection ?? new GitIndexProjection(
                context,
                gitObjects,
                this.BlobSizes,
                repoMetadata,
                fileSystemVirtualizer,
                placeholders,
                this.modifiedPaths);

            if (backgroundFileSystemTaskRunner != null)
            {
                this.backgroundFileSystemTaskRunner = backgroundFileSystemTaskRunner;
                this.backgroundFileSystemTaskRunner.SetCallbacks(
                    this.PreBackgroundOperation,
                    this.ExecuteBackgroundOperation,
                    this.PostBackgroundOperation);
            }
            else
            {
                this.backgroundFileSystemTaskRunner = new BackgroundFileSystemTaskRunner(
                    this.context,
                    this.PreBackgroundOperation,
                    this.ExecuteBackgroundOperation,
                    this.PostBackgroundOperation,
                    Path.Combine(context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.BackgroundFileSystemTasks));
            }

            this.enableGitStatusCache = gitStatusCache != null;

            // If the status cache is not enabled, create a dummy GitStatusCache that will never be initialized
            // This lets us from having to add null checks to callsites into GitStatusCache.
            this.gitStatusCache = gitStatusCache ?? new GitStatusCache(context, TimeSpan.Zero);

            this.logsHeadPath = Path.Combine(this.context.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Logs.Head);

            EventMetadata metadata = new EventMetadata();

            metadata.Add("placeholders.Count", placeholders.EstimatedCount);
            metadata.Add("background.Count", this.backgroundFileSystemTaskRunner.Count);
            metadata.Add(TracingConstants.MessageKey.InfoMessage, $"{nameof(FileSystemCallbacks)} created");
            this.context.Tracer.RelatedEvent(EventLevel.Informational, $"{nameof(FileSystemCallbacks)}_Constructor", metadata);
        }
示例#11
0
        public FileSystemCallbacks(
            GVFSContext context,
            GVFSGitObjects gitObjects,
            RepoMetadata repoMetadata,
            BlobSizes blobSizes,
            GitIndexProjection gitIndexProjection,
            BackgroundFileSystemTaskRunner backgroundFileSystemTaskRunner,
            FileSystemVirtualizer fileSystemVirtualizer)
        {
            this.logsHeadFileProperties = null;
            this.postFetchJobLock       = new object();

            this.context               = context;
            this.gitObjects            = gitObjects;
            this.fileSystemVirtualizer = fileSystemVirtualizer;

            this.placeHolderCreationCount = new ConcurrentDictionary <string, PlaceHolderCreateCounter>(StringComparer.OrdinalIgnoreCase);

            string error;

            if (!ModifiedPathsDatabase.TryLoadOrCreate(
                    this.context.Tracer,
                    Path.Combine(this.context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.ModifiedPaths),
                    this.context.FileSystem,
                    out this.modifiedPaths,
                    out error))
            {
                throw new InvalidRepoException(error);
            }

            this.BlobSizes = blobSizes;
            this.BlobSizes.Initialize();

            PlaceholderListDatabase placeholders;

            if (!PlaceholderListDatabase.TryCreate(
                    this.context.Tracer,
                    Path.Combine(this.context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.PlaceholderList),
                    this.context.FileSystem,
                    out placeholders,
                    out error))
            {
                throw new InvalidRepoException(error);
            }

            this.GitIndexProjection = gitIndexProjection ?? new GitIndexProjection(
                context,
                gitObjects,
                this.BlobSizes,
                repoMetadata,
                fileSystemVirtualizer,
                placeholders,
                this.modifiedPaths);

            this.backgroundFileSystemTaskRunner = backgroundFileSystemTaskRunner ?? new BackgroundFileSystemTaskRunner(
                this.context,
                this.PreBackgroundOperation,
                this.ExecuteBackgroundOperation,
                this.PostBackgroundOperation,
                Path.Combine(context.Enlistment.DotGVFSRoot, GVFSConstants.DotGVFS.Databases.BackgroundFileSystemTasks));

            this.logsHeadPath = Path.Combine(this.context.Enlistment.WorkingDirectoryRoot, GVFSConstants.DotGit.Logs.Head);

            EventMetadata metadata = new EventMetadata();

            metadata.Add("placeholders.Count", placeholders.EstimatedCount);
            metadata.Add("background.Count", this.backgroundFileSystemTaskRunner.Count);
            metadata.Add(TracingConstants.MessageKey.InfoMessage, $"{nameof(FileSystemCallbacks)} created");
            this.context.Tracer.RelatedEvent(EventLevel.Informational, $"{nameof(FileSystemCallbacks)}_Constructor", metadata);
        }