public UploadResumeReport GetRemainingFiles() { var filesToCheck = _filesToCheck.ToList(); int filesExistCount = 0; for (int i = 0; i < filesToCheck.Count(); i++) { IZipEntry zipEntry = filesToCheck[i]; _notifier.CheckingForUploadedFile(_gameName, zipEntry.FileName); if (!_xboxGameRepository.Exists(_gameName, zipEntry.FileName, zipEntry.UncompressedSize)) { break; } filesExistCount++; _notifier.FileAlreadyExists(_gameName, zipEntry.FileName); } var filesUploaded = filesToCheck.GetRange(0, filesExistCount); long sizeUploaded = filesUploaded.Sum(x => x.UncompressedSize); filesToCheck.RemoveRange(0, filesExistCount); return(new UploadResumeReport(filesToCheck, sizeUploaded)); }
public UploadResumeReport GetRemainingFiles() { int lowerBound = 0; int upperBound = _filesToCheck.Count - 1; int index = upperBound / 2; int resumePosition = index; var filesToCheckList = _filesToCheck.ToList(); bool resumePointFound = false; // Check the first file explicitly var zipEntry = filesToCheckList[0]; if (!_xboxGameRepository.Exists(_gameName, zipEntry.FileName, zipEntry.UncompressedSize)) { return(new UploadResumeReport(filesToCheckList, 0)); } while (lowerBound <= upperBound) { zipEntry = filesToCheckList[index]; _notifier.CheckingForUploadedFile(_gameName, zipEntry.FileName); if (_xboxGameRepository.Exists(_gameName, zipEntry.FileName, zipEntry.UncompressedSize)) { resumePosition = index; _notifier.FileAlreadyExists(_gameName, zipEntry.FileName); lowerBound = index + 1; index = (lowerBound + upperBound) / 2; } else { upperBound = index - 1; index = (lowerBound + upperBound) / 2; } } var filesUploaded = filesToCheckList.GetRange(0, resumePosition + 1); long sizeUploaded = filesUploaded.Sum(x => x.UncompressedSize); filesToCheckList.RemoveRange(0, resumePosition + 1); return(new UploadResumeReport(filesToCheckList, sizeUploaded)); }