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()); }
IEnumerable <string> GetExistingObjects(IEnumerable <FileObjectMapping> objects) => GetMetaDataFilesOrderedBySize() .Select(x => x.Checksum) .Except(objects.Select(x => x.Checksum)) .Select(x => Repository.GetObjectSubPath(x));