Пример #1
0
        public void ServiceStartTriggersAutoMountForCurrentUser()
        {
            Mock <IRepoRegistry> repoRegistry = new Mock <IRepoRegistry>(MockBehavior.Strict);

            repoRegistry.Setup(r => r.AutoMountRepos(ExpectedActiveUserId.ToString(), ExpectedSessionId, true));
            repoRegistry.Setup(r => r.TraceStatus());

            GVFSService service = new GVFSService(
                this.tracer,
                serviceName: null,
                repoRegistry: repoRegistry.Object);

            service.Run();

            repoRegistry.VerifyAll();
        }
Пример #2
0
        protected override void Execute(GVFSEnlistment enlistment)
        {
            this.Output.WriteLine("Most recent log files:");

            string gvfsLogsRoot = enlistment.GVFSLogsRoot;

            this.DisplayMostRecent(gvfsLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Clone), GVFSConstants.LogFileTypes.Clone);
            this.DisplayMostRecent(gvfsLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Dehydrate), GVFSConstants.LogFileTypes.Dehydrate);
            this.DisplayMostRecent(gvfsLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Mount), GVFSConstants.LogFileTypes.Mount);
            this.DisplayMostRecent(gvfsLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Prefetch), GVFSConstants.LogFileTypes.Prefetch);
            this.DisplayMostRecent(gvfsLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Repair), GVFSConstants.LogFileTypes.Repair);

            string serviceLogsRoot = GVFSService.GetServiceLogsRoot(this.ServiceName);

            this.DisplayMostRecent(serviceLogsRoot, GetLogFilePatternForType(GVFSConstants.LogFileTypes.Service), GVFSConstants.LogFileTypes.Service);
        }
Пример #3
0
        protected override void Execute(GVFSEnlistment enlistment)
        {
            string diagnosticsRoot = Path.Combine(enlistment.DotGVFSRoot, "diagnostics");

            if (!Directory.Exists(diagnosticsRoot))
            {
                Directory.CreateDirectory(diagnosticsRoot);
            }

            string archiveFolderPath = Path.Combine(diagnosticsRoot, "gvfs_" + DateTime.Now.ToString("yyyyMMdd_HHmmss"));

            Directory.CreateDirectory(archiveFolderPath);

            using (FileStream diagnosticLogFile = new FileStream(Path.Combine(archiveFolderPath, "diagnostics.log"), FileMode.CreateNew))
                using (this.diagnosticLogFileWriter = new StreamWriter(diagnosticLogFile))
                {
                    this.WriteMessage("Collecting diagnostic info into temp folder " + archiveFolderPath);

                    this.WriteMessage(string.Empty);
                    this.WriteMessage("gvfs version " + ProcessHelper.GetCurrentProcessVersion());
                    this.WriteMessage(GitProcess.Version(enlistment).Output);
                    this.WriteMessage(GitProcess.GetInstalledGitBinPath());
                    this.WriteMessage(string.Empty);
                    this.WriteMessage("Enlistment root: " + enlistment.EnlistmentRoot);
                    this.WriteMessage("Repo URL: " + enlistment.RepoUrl);
                    this.WriteMessage("Objects URL: " + enlistment.ObjectsEndpointUrl);
                    this.WriteMessage(string.Empty);

                    this.WriteMessage("Copying .gvfs folder...");
                    this.CopyAllFiles(enlistment.EnlistmentRoot, archiveFolderPath, GVFSConstants.DotGVFS.Root, copySubFolders: false);

                    this.WriteMessage("Copying GVFlt logs...");
                    this.FlushGvFltLogBuffers();
                    string system32LogFilesPath = Environment.ExpandEnvironmentVariables(System32LogFilesRoot);
                    this.CopyAllFiles(system32LogFilesPath, archiveFolderPath, GVFltLogFolderName, copySubFolders: false);

                    this.WriteMessage("Checking on GVFS...");
                    this.RunAndRecordGVFSVerb <LogVerb>(archiveFolderPath, "gvfs_log.txt");
                    ReturnCode statusResult = this.RunAndRecordGVFSVerb <StatusVerb>(archiveFolderPath, "gvfs_status.txt");

                    if (statusResult == ReturnCode.Success)
                    {
                        this.WriteMessage("GVFS is mounted. Unmounting so we can read files that GVFS has locked...");
                        this.RunAndRecordGVFSVerb <UnmountVerb>(archiveFolderPath, "gvfs_unmount.txt");
                    }
                    else
                    {
                        this.WriteMessage("GVFS was not mounted.");
                    }

                    this.WriteMessage("Checking Defender exclusion...");
                    this.WriteAntiVirusExclusions(enlistment.EnlistmentRoot, archiveFolderPath, "DefenderExclusionInfo.txt");

                    this.WriteMessage("Copying .git folder...");
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Root, copySubFolders: false);
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Hooks.Root, copySubFolders: false);
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Info.Root, copySubFolders: false);
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Logs.Root, copySubFolders: true);
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Refs.Root, copySubFolders: true);
                    this.CopyAllFiles(enlistment.WorkingDirectoryRoot, archiveFolderPath, GVFSConstants.DotGit.Objects.Info.Root, copySubFolders: false);

                    this.CopyEsentDatabase <long, GVFltCallbacks.BackgroundGitUpdate>(
                        enlistment.DotGVFSRoot,
                        Path.Combine(archiveFolderPath, GVFSConstants.DotGVFS.Root),
                        GVFSConstants.DatabaseNames.BackgroundGitUpdates);
                    this.CopyEsentDatabase <string, string>(
                        enlistment.DotGVFSRoot,
                        Path.Combine(archiveFolderPath, GVFSConstants.DotGVFS.Root),
                        GVFSConstants.DatabaseNames.PlaceholderList);
                    this.CopyEsentDatabase <string, long>(
                        enlistment.DotGVFSRoot,
                        Path.Combine(archiveFolderPath, GVFSConstants.DotGVFS.Root),
                        GVFSConstants.DatabaseNames.BlobSizes);
                    this.CopyEsentDatabase <string, string>(
                        enlistment.DotGVFSRoot,
                        Path.Combine(archiveFolderPath, GVFSConstants.DotGVFS.Root),
                        GVFSConstants.DatabaseNames.RepoMetadata);

                    this.WriteMessage("Copying GVFS.Service logs and data...");
                    this.CopyAllFiles(
                        GVFSService.GetServiceDataRoot(string.Empty),
                        archiveFolderPath,
                        this.ServiceName,
                        copySubFolders: true);

                    this.WriteMessage(string.Empty);
                    this.WriteMessage("Remounting GVFS...");
                    ReturnCode mountResult = this.RunAndRecordGVFSVerb <MountVerb>(archiveFolderPath, "gvfs_mount.txt");
                    if (mountResult == ReturnCode.Success)
                    {
                        this.WriteMessage("Mount succeeded");
                    }
                    else
                    {
                        this.WriteMessage("Failed to remount. The reason for failure was captured.");
                    }

                    this.CopyAllFiles(enlistment.DotGVFSRoot, Path.Combine(archiveFolderPath, GVFSConstants.DotGVFS.Root), "logs", copySubFolders: false);
                }

            string zipFilePath = archiveFolderPath + ".zip";

            ZipFile.CreateFromDirectory(archiveFolderPath, zipFilePath);
            PhysicalFileSystem.RecursiveDelete(archiveFolderPath);

            this.Output.WriteLine();
            this.Output.WriteLine("Diagnostics complete. All of the gathered info, as well as all of the output above, is captured in");
            this.Output.WriteLine(zipFilePath);
            this.Output.WriteLine();
            this.Output.WriteLine("If you are experiencing an issue, please email the GVFS team with your repro steps and include this zip file.");
        }