private void HandleAllFileAddOperations() { using (FastFetchLibGit2Repo repo = new FastFetchLibGit2Repo(this.tracer, this.enlistment.WorkingDirectoryRoot)) { string availableBlob; while (this.AvailableBlobShas.TryTake(out availableBlob, Timeout.Infinite)) { if (this.HasFailures) { return; } Interlocked.Increment(ref this.shasReceived); HashSet <string> paths; if (this.diff.FileAddOperations.TryRemove(availableBlob, out paths)) { try { long written; if (!repo.TryCopyBlobToFile(availableBlob, paths, out written)) { // TryCopyBlobTo emits an error event. this.HasFailures = true; } Interlocked.Add(ref this.bytesWritten, written); foreach (string path in paths) { this.AddedOrEditedLocalFiles.Add(path); if (Interlocked.Increment(ref this.fileWriteCount) % NumOperationsPerStatus == 0) { EventMetadata metadata = new EventMetadata(); metadata.Add("AvailableBlobsQueued", this.AvailableBlobShas.Count); metadata.Add("NumberBlobsNeeded", this.diff.FileAddOperations.Count); this.tracer.RelatedEvent(EventLevel.Informational, "CheckoutStatus", metadata); } } } catch (Exception ex) { EventMetadata errorData = new EventMetadata(); errorData.Add("Operation", "WriteFile"); this.tracer.RelatedError(errorData, ex.ToString()); this.HasFailures = true; } } } } }
protected override void DoWork() { string blobId; using (FastFetchLibGit2Repo repo = new FastFetchLibGit2Repo(this.tracer, this.enlistment.WorkingDirectoryRoot)) { while (this.requiredBlobs.TryTake(out blobId, Timeout.Infinite)) { if (this.alreadyFoundBlobIds.Add(blobId)) { if (!repo.ObjectExists(blobId)) { Interlocked.Increment(ref this.missingBlobCount); this.MissingBlobs.Add(blobId); } else { Interlocked.Increment(ref this.availableBlobCount); this.AvailableBlobs.Add(blobId); } } } } }