Example #1
0
        public async Task <bool> Commit(ILogger log, CancellationToken token)
        {
            var perfTracker = LocalCache.PerfTracker;

            // Find all files with changes
            var withChanges = Files.Values.Where(e => e.HasChanges).ToList();

            // Order files so that nupkgs are pushed first to help clients avoid
            // missing files during the push.
            withChanges.Sort(new SleetFileComparer());

            if (withChanges.Count > 0)
            {
                var bytes = withChanges.Select(e => e as FileBase)
                            .Where(e => e != null)
                            .Sum(e => e.LocalFileSizeIfExists);

                // Create tasks to run in parallel
                var tasks = withChanges.Select(e => GetCommitFileFunc(e, log, token));

                var message = $"Files committed: {withChanges.Count} Size: {PrintUtility.GetBytesString(bytes)} Total upload time: " + "{0}";
                using (var timer = PerfEntryWrapper.CreateSummaryTimer(message, perfTracker))
                {
                    // Push in parallel
                    await TaskUtils.RunAsync(
                        tasks : tasks,
                        useTaskRun : true,
                        maxThreads : 8,
                        token : token);
                }
            }

            return(true);
        }
Example #2
0
 public override string GetMessage(TimeSpan timeSpan)
 {
     return($"({Operation.ToString().ToUpperInvariant()}) {File.PathAndQuery} : {PrintUtility.GetTimeString(timeSpan)}");
 }
Example #3
0
 public override string GetMessage(TimeSpan timeSpan)
 {
     return(string.Format(Key, PrintUtility.GetTimeString(timeSpan)));
 }