Ejemplo n.º 1
0
        public async Task <string[]> Update(IEnumerable <Uri> remotes, StatusRepo repo, bool skipWhenFileMatches = true)
        {
            var objects     = GetNeededObjects(skipWhenFileMatches);
            var doneObjects = new ConcurrentBag <FileObjectMapping>();
            var relObjects  = objects.OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FO.FilePath))
                              .Select(
                x => new FileFetchInfo(Repository.GetObjectSubPath(x.FO), x.FO.FilePath)
            {
                OnComplete = () => doneObjects.Add(x.FO)
            })
                              .ToArray();

            StatusRepo.ProcessSize(GetExistingObjects(objects.Select(x => x.FO)), Repository.ObjectsPath,
                                   MetaData.SizePacked);

            // TODO: Abort support!
            // TODO: Progress fix??!
            try {
                await DownloadObjects(remotes, repo, relObjects, Repository.ObjectsPath).ConfigureAwait(false);
            } finally {
                Repository.ReAddObject(doneObjects.Select(x => x.Checksum).ToArray());
            }

            return(relObjects.Select(x => x.FilePath).ToArray());
        }
Ejemplo n.º 2
0
        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());
        }