async Task <string[]> UpdateMultiple(IReadOnlyCollection <Package.ObjectMap> objects, IReadOnlyCollection <Package> packages, IReadOnlyCollection <Uri> remotes) { if (!objects.Any()) { Repository.Log("No remote objects to resolve"); return(new string[0]); } Repository.Log("Resolving {0} remote objects for {1} packages from {2} remotes, please be patient..", objects.Count, packages.Count, remotes.Count); var doneObjects = new ConcurrentBag <FileObjectMapping>(); var relObjects = objects.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FO.FilePath)) .Select(x => new FileFetchInfo(Repo.GetObjectSubPath(x.FO), x.FO.FilePath) { ExistingPath = x.ExistingObject != null ? Repo.GetObjectSubPath(x.ExistingObject) : null, OnComplete = () => doneObjects.Add(x.FO) }) .ToArray(); StatusRepo.Reset(RepoStatus.Downloading, objects.Count); StatusRepo.ProcessSize(GetExistingObjects(objects.Select(x => x.FO), packages), Repo.ObjectsPath, GetPackedSize(packages)); try { await Package.DownloadObjects(remotes, StatusRepo, relObjects, Repo.ObjectsPath).ConfigureAwait(false); } finally { Repo.ReAddObject(doneObjects.Select(x => x.Checksum).ToArray()); } return(relObjects.Select(x => x.FilePath).ToArray()); }
private async Task GetDependencyTreeInternal(IReadOnlyCollection <Dependency> dependencies, bool noCheckout, bool useFullName, List <string> list, List <string> list2, List <Package> packages) { StatusRepo.Reset(RepoStatus.Resolving, dependencies.Count); var specificVersions = dependencies.Select(x => ResolvePackageName(x.GetFullName())).ToArray(); await FetchAllRequestedPackages(specificVersions).ConfigureAwait(false); var done = specificVersions.ToList(); foreach (var dep in specificVersions) { Repo.AddPackage(dep.GetFullName()); await ResolveDependencies(list, list2, packages, dep, done, useFullName, noCheckout) .ConfigureAwait(false); } foreach (var package in packages) { package.StatusRepo = StatusRepo; } if (packages.GroupBy(x => x.MetaData.Name.ToLower()).Any(x => x.Count() > 1)) { throw new InvalidOperationException("Somehow got duplicate packges: " + string.Join(", ", packages.GroupBy(x => x.MetaData.Name.ToLower()) .Where(x => x.Count() > 1) .Select(x => x.Key))); } }
public async Task <List <Package> > Checkout(IReadOnlyCollection <string> packageNames, bool?useFullNameOverride = null) { StatusRepo.Reset(RepoStatus.CheckOut, packageNames.Count()); var packages = new List <Package>(); foreach (var p in packageNames) { packages.Add(await CheckoutAsync(p, useFullNameOverride).ConfigureAwait(false)); } return(packages); }
public async Task <Package[]> ProcessPackages(IEnumerable <Dependency> packageNames, bool?useFullNameOverride = null, bool noCheckout = false, bool skipWhenFileMatches = true) { if (Repo.Config.OperationMode == RepositoryOperationMode.SinglePackage) { throw new Exception("Cannot process repository in SinglePackage mode"); } var useFullName = Repo.Config.UseVersionedPackageFolders; if (useFullNameOverride.HasValue) { useFullName = useFullNameOverride.Value; } // Add this package, then add it's dependencies, and so on // The list should be unique based on package (name + version + branch) // If there is a conflict, the process should be aborted. A conflict can arise when one package needs a version locked on X, and another on Y // First resolve all dependencies // So that we can determine conflicting dependencies, remove double dependencies, etc. // Let the package Download itself, by providing it with sources (remotes) var packages = (await GetDependencyTree(packageNames.ToArray(), noCheckout, useFullName).ConfigureAwait(false)) .OrderByDescending(x => x.MetaData.SizePacked).ToArray(); StatusRepo.Reset(RepoStatus.Processing, packages.Length); if (Settings.GlobalWorkingPath != null) { var s = Settings.GlobalWorkingPath.ToString(); foreach (var p in packages) { p.SetWorkingPath(s); } } if (LegacyMode) { await ProcessLegacy(noCheckout, skipWhenFileMatches, packages).ConfigureAwait(false); } else { await ProcessModern(noCheckout, packages).ConfigureAwait(false); } await Repo.SaveAsync().ConfigureAwait(false); return(packages.ToArray()); }
void HandleMissingObjects(List <Package.ObjectMap> missingObjects) { var currentPackage = MetaData.GetFullName(); var packages = Repository.GetPackagesList() .Where(x => !x.Equals(currentPackage)) .OrderByDescending(x => x.StartsWith(MetaData.Name)).ToArray(); if (packages.Any()) { ProcessMissingObjects(missingObjects, packages); } var resolvableObjects = missingObjects.Where(x => x.ExistingObject != null).ToArray(); StatusRepo.Reset(RepoStatus.Copying, resolvableObjects.Length); foreach (var o in resolvableObjects) { this.Logger() .Info("Found local previous version match for {0}", o.FO.FilePath, o.ExistingObject, o.FO.Checksum); missingObjects.Remove(o); } StatusRepo.Reset(RepoStatus.Packing, missingObjects.Count); var resolvedObjects = new List <Package.ObjectMap>(); foreach (var o in missingObjects) { ProcessMissingObject(o, resolvedObjects); } Repository.ReAddObject(resolvedObjects.Select(x => x.ExistingObject).ToArray()); foreach (var o in resolvedObjects) { missingObjects.Remove(o); } Repository.Log( "\nFound {0} missing objects, resolved {1} candidates from other packages and {2} from uncompressed files", missingObjects.Count + resolvedObjects.Count + resolvableObjects.Length, resolvableObjects.Length, resolvedObjects.Count); }
private async Task ProcessCheck(bool noCheckout, bool skipWhenFileMatches, IReadOnlyCollection <Package> packages, ICollection <Package> syncedPackages, Package.ObjectMap[] objectsToFetch) { StatusRepo.Reset(RepoStatus.CheckOut, packages.Count); var i = 0; syncedPackages.AddRange(packages); var components = packages.Select(x => new ProgressLeaf(x.MetaData.Name)).ToArray(); if (!noCheckout) { foreach (var package in packages) { var p = components[i++]; await p.Do(() => ProcessPackageInternal(package, p)).ConfigureAwait(false); } } if (!noCheckout && skipWhenFileMatches) { Repo.DeleteObject(objectsToFetch.Select(x => new ObjectInfo(x.FO.Checksum, x.FO.Checksum))); // nasty using checksum for packed checksum or ? not needed here anyway?? } }
public Task <IReadOnlyCollection <SpecificVersion> > CleanPackages(int limit, IReadOnlyCollection <SpecificVersion> keepVersions, params string[] packages) { StatusRepo.Reset(RepoStatus.Cleaning, packages.Length); return(Repo.CleanPackageAsync(packages, keepVersions, limit)); }