Esempio n. 1
0
        public static async Task <bool> RunAsync(LocalSettings settings, ISleetFileSystem source, string outputPath, bool ignoreErrors, bool noLock, bool skipExisting, ILogger log)
        {
            var token = CancellationToken.None;
            ISleetFileSystemLock feedLock = null;
            var success     = true;
            var perfTracker = source.LocalCache.PerfTracker;

            using (var timer = PerfEntryWrapper.CreateSummaryTimer("Total execution time: {0}", perfTracker))
            {
                // Check if already initialized
                try
                {
                    if (!noLock)
                    {
                        // Lock
                        feedLock = await SourceUtility.VerifyInitAndLock(settings, source, "Download", log, token);

                        // Validate source
                        await UpgradeUtility.EnsureCompatibility(source, log, token);
                    }

                    success = await DownloadPackages(settings, source, outputPath, ignoreErrors, log, token);
                }
                finally
                {
                    feedLock?.Dispose();
                }
            }

            // Write out perf summary
            await perfTracker.LogSummary(log);

            return(success);
        }
Esempio n. 2
0
        public static async Task <bool> RunAsync(LocalSettings settings, ISleetFileSystem source, List <string> inputs, bool force, bool skipExisting, ILogger log)
        {
            var token       = CancellationToken.None;
            var now         = DateTimeOffset.UtcNow;
            var success     = false;
            var perfTracker = source.LocalCache.PerfTracker;

            await log.LogAsync(LogLevel.Minimal, $"Reading feed {source.BaseURI.AbsoluteUri}");

            using (var timer = PerfEntryWrapper.CreateSummaryTimer("Total execution time: {0}", perfTracker))
            {
                // Partition package inputs to avoid reading 100K nuspecs at the same time.
                var packagePaths = GetPackagePaths(inputs);
                var inputBatches = packagePaths.Partition(DefaultBatchSize);
                ISleetFileSystemLock feedLock = null;

                try
                {
                    for (var i = 0; i < inputBatches.Count; i++)
                    {
                        var inputBatch = inputBatches[i];
                        if (inputBatches.Count > 1)
                        {
                            await log.LogAsync(LogLevel.Minimal, $"Pushing {inputBatch.Count} packages. Batch: {i+1} / {inputBatches.Count}");
                        }

                        // Read packages before locking the feed the first time.
                        var packages = new List <PackageInput>(await GetPackageInputs(inputBatch, now, perfTracker, log));

                        if (feedLock == null)
                        {
                            string lockMessage = null;
                            if (packages.Count > 0)
                            {
                                lockMessage = $"Push of {packages[0].Identity.ToString()}";
                            }

                            // Check if already initialized
                            feedLock = await SourceUtility.VerifyInitAndLock(settings, source, lockMessage, log, token);

                            // Validate source
                            await SourceUtility.ValidateFeedForClient(source, log, token);
                        }

                        // Push
                        success = await PushPackages(settings, source, packages, force, skipExisting, log, token);
                    }
                }
                finally
                {
                    // Unlock the feed
                    feedLock?.Dispose();
                }
            }

            // Write out perf summary
            await perfTracker.LogSummary(log);

            return(success);
        }