Пример #1
0
        private void MountAndStartWorkingDirectoryCallbacks(GVFSContext context)
        {
            HttpGitObjects httpGitObjects = new HttpGitObjects(context.Tracer, context.Enlistment, Environment.ProcessorCount);

            if (!httpGitObjects.TryRefreshCredentials())
            {
                this.FailMountAndExit("Failed to obtain git credentials");
            }

            // Checking the disk layout version is done before this point in GVFS.CommandLine.MountVerb.PreExecute
            RepoMetadata repoMetadata = new RepoMetadata(this.enlistment.DotGVFSRoot);

            this.gitObjects     = new GVFSGitObjects(context, httpGitObjects);
            this.gvfltCallbacks = this.CreateOrReportAndExit(() => new GVFltCallbacks(context, this.gitObjects, repoMetadata), "Failed to create src folder callbacks");

            int    persistedVersion;
            string error;

            if (!repoMetadata.TryGetOnDiskLayoutVersion(out persistedVersion, out error))
            {
                this.FailMountAndExit("Error: {0}", error);
            }

            if (!repoMetadata.OnDiskVersionUsesAlwaysExclude())
            {
                // Want this as close to repoMetadata.SaveCurrentDiskLayoutVersion() as possible to avoid possible corrupt states.
                this.UpdateToAlwaysExcludeFile(repoMetadata);
            }

            try
            {
                if (!this.gvfltCallbacks.TryStart(out error))
                {
                    this.FailMountAndExit("Error: {0}. \r\nPlease confirm that gvfs clone completed without error.", error);
                }
            }
            catch (Exception e)
            {
                this.FailMountAndExit("Failed to initialize src folder callbacks. {0}", e.ToString());
            }

            repoMetadata.SaveCurrentDiskLayoutVersion();
            repoMetadata.SetAlwaysExcludeInvalid(false);

            this.AcquireFolderLocks(context);

            this.heartbeat = new HeartbeatThread(this.tracer, this.gvfltCallbacks);
            this.heartbeat.Start();
        }