示例#1
0
        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 <PathWithMode> 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 (PathWithMode modeAndPath in paths)
                            {
                                this.AddedOrEditedLocalFiles.Add(modeAndPath.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;
                        }
                    }
                }
            }
        }
示例#2
0
文件: FetchHelper.cs 项目: yyqyu/GVFS
        protected void DownloadMissingCommit(string commitSha, GitObjects gitObjects)
        {
            EventMetadata startMetadata = new EventMetadata();

            startMetadata.Add("CommitSha", commitSha);

            using (ITracer activity = this.Tracer.StartActivity("DownloadTrees", EventLevel.Informational, Keywords.Telemetry, startMetadata))
            {
                using (FastFetchLibGit2Repo repo = new FastFetchLibGit2Repo(this.Tracer, this.Enlistment.WorkingDirectoryRoot))
                {
                    if (!repo.ObjectExists(commitSha))
                    {
                        if (!gitObjects.TryDownloadCommit(commitSha))
                        {
                            EventMetadata metadata = new EventMetadata();
                            metadata.Add("ObjectsEndpointUrl", this.ObjectRequestor.CacheServer.ObjectsEndpointUrl);
                            activity.RelatedError(metadata, "Could not download commits");
                            throw new FetchException("Could not download commits from {0}", this.ObjectRequestor.CacheServer.ObjectsEndpointUrl);
                        }
                    }
                }
            }
        }