private void MountAndStartWorkingDirectoryCallbacks(CacheServerInfo cache) { string error; if (!this.context.Enlistment.Authentication.TryRefreshCredentials(this.context.Tracer, out error)) { this.FailMountAndExit("Failed to obtain git credentials: " + error); } GitObjectsHttpRequestor objectRequestor = new GitObjectsHttpRequestor(this.context.Tracer, this.context.Enlistment, cache, this.retryConfig); this.gitObjects = new GVFSGitObjects(this.context, objectRequestor); FileSystemVirtualizer virtualizer = this.CreateOrReportAndExit(() => GVFSPlatformLoader.CreateFileSystemVirtualizer(this.context, this.gitObjects), "Failed to create src folder virtualizer"); GitStatusCache gitStatusCache = (!this.context.Unattended && GVFSPlatform.Instance.IsGitStatusCacheSupported()) ? new GitStatusCache(this.context, this.gitStatusCacheConfig) : null; if (gitStatusCache != null) { this.tracer.RelatedInfo("Git status cache enabled. Backoff time: {0}ms", this.gitStatusCacheConfig.BackoffTime.TotalMilliseconds); } this.fileSystemCallbacks = this.CreateOrReportAndExit(() => new FileSystemCallbacks(this.context, this.gitObjects, RepoMetadata.Instance, virtualizer, gitStatusCache), "Failed to create src folder callback listener"); if (!this.context.Unattended) { this.prefetcher = this.CreateOrReportAndExit(() => new BackgroundPrefetcher(this.tracer, this.enlistment, this.context.FileSystem, this.gitObjects), "Failed to start background prefetcher"); } int majorVersion; int minorVersion; if (!RepoMetadata.Instance.TryGetOnDiskLayoutVersion(out majorVersion, out minorVersion, out error)) { this.FailMountAndExit("Error: {0}", error); } if (majorVersion != RepoMetadata.DiskLayoutVersion.CurrentMajorVersion) { this.FailMountAndExit( "Error: On disk version ({0}) does not match current version ({1})", majorVersion, RepoMetadata.DiskLayoutVersion.CurrentMajorVersion); } try { if (!this.fileSystemCallbacks.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()); } this.heartbeat = new HeartbeatThread(this.tracer, this.fileSystemCallbacks); this.heartbeat.Start(); }
public void LaunchBackgroundJobSucceeds() { using (CommonRepoSetup setup = new CommonRepoSetup()) using (BackgroundPrefetcher prefetcher = new BackgroundPrefetcher(setup.Context.Tracer, setup.Context.Enlistment, setup.Context.FileSystem, setup.GitObjects)) { prefetcher.LaunchPrefetchJobIfIdle().ShouldBeTrue(); prefetcher.WaitForPrefetchToFinish(); } }
public void LaunchPrefetchJobIfIdleDoesNotLaunchSecondThreadIfFirstInProgress() { using (CommonRepoSetup setup = new CommonRepoSetup()) { BlockedCreateDirectoryFileSystem fileSystem = new BlockedCreateDirectoryFileSystem(setup.FileSystem.RootDirectory); using (BackgroundPrefetcher prefetcher = new BackgroundPrefetcher( setup.Context.Tracer, setup.Context.Enlistment, fileSystem, setup.GitObjects)) { prefetcher.LaunchPrefetchJobIfIdle().ShouldBeTrue(); prefetcher.LaunchPrefetchJobIfIdle().ShouldBeFalse(); fileSystem.UnblockCreateDirectory(); prefetcher.WaitForPrefetchToFinish(); } } }
private void UnmountAndStopWorkingDirectoryCallbacks() { if (this.prefetcher != null) { this.prefetcher.Dispose(); this.prefetcher = null; } if (this.heartbeat != null) { this.heartbeat.Stop(); this.heartbeat = null; } if (this.fileSystemCallbacks != null) { this.fileSystemCallbacks.Stop(); this.fileSystemCallbacks.Dispose(); this.fileSystemCallbacks = null; } }