public RemoteResource GetDiffPackageResource(int versionId, string keySecret, string countryCode, CancellationToken cancellationToken) { Checks.ArgumentValidVersionId(versionId, "versionId"); DebugLogger.Log("Getting diff package resource."); DebugLogger.LogVariable(versionId, "versionId"); DebugLogger.LogVariable(keySecret, "keySecret"); RemoteResource resource = new RemoteResource(); var summary = _mainApiConnection.GetAppVersionDiffSummary(_appSecret, versionId, cancellationToken); var urls = _mainApiConnection.GetAppVersionDiffUrls(_appSecret, versionId, countryCode, keySecret, cancellationToken); resource.Size = summary.Size; resource.HashCode = summary.HashCode; resource.ChunksData = ConvertToChunksData(summary.Chunks); resource.ResourceUrls = urls; return(resource); }
public RemoteResourceDownloader([NotNull] string destinationFilePath, [NotNull] string destinationMetaPath, RemoteResource resource, CreateNewHttpDownloader createNewHttpDownloader, CreateNewChunkedHttpDownloader createNewChunkedHttpDownloader) { if (destinationFilePath == null) { throw new ArgumentNullException("destinationFilePath"); } if (destinationMetaPath == null) { throw new ArgumentNullException("destinationMetaPath"); } _logger = PatcherLogManager.DefaultLogger; _destinationFilePath = destinationFilePath; _destinationMetaPath = destinationMetaPath; _resource = resource; _createNewHttpDownloader = createNewHttpDownloader; _createNewChunkedHttpDownloader = createNewChunkedHttpDownloader; }
public RemoteResource GetDiffPackageResource(int versionId, string keySecret, string countryCode) { Checks.ArgumentValidVersionId(versionId, "versionId"); DebugLogger.Log("Getting diff package resource."); DebugLogger.LogVariable(versionId, "versionId"); DebugLogger.LogVariable(keySecret, "keySecret"); RemoteResource resource = new RemoteResource(); var summary = _mainApiConnection.GetAppVersionDiffSummary(_appSecret, versionId); var torrentUrl = _mainApiConnection.GetAppVersionDiffTorrentUrl(_appSecret, versionId, keySecret); var urls = _mainApiConnection.GetAppVersionDiffUrls(_appSecret, versionId, countryCode); // TODO: Add key secret checking resource.Size = summary.Size; resource.HashCode = summary.HashCode; resource.ChunksData = ConvertToChunksData(summary.Chunks); resource.TorrentUrls = new[] { torrentUrl.Url }; resource.ResourceUrls = urls; return(resource); }
public RemoteResourceDownloader(string destinationFilePath, string destinationMetaPath, RemoteResource resource, bool useTorrents, CreateNewHttpDownloader createNewHttpDownloader, CreateNewChunkedHttpDownloader createNewChunkedHttpDownloader, CreateNewTorrentDownloader createNewTorrentDownloader) { Checks.ArgumentParentDirectoryExists(destinationFilePath, "destinationFilePath"); Checks.ArgumentValidRemoteResource(resource, "resource"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(destinationFilePath, "destinationFilePath"); DebugLogger.LogVariable(resource, "resource"); DebugLogger.LogVariable(useTorrents, "useTorrents"); _destinationFilePath = destinationFilePath; _destinationMetaPath = destinationMetaPath; _resource = resource; _useTorrents = useTorrents; _createNewHttpDownloader = createNewHttpDownloader; _createNewChunkedHttpDownloader = createNewChunkedHttpDownloader; _createNewTorrentDownloader = createNewTorrentDownloader; }
public RemoteResource GetContentPackageResource(int versionId, string keySecret, string countryCode) { Checks.ArgumentValidVersionId(versionId, "versionId"); DebugLogger.Log("Getting content package resource."); DebugLogger.LogVariable(versionId, "versionId"); DebugLogger.LogVariable(keySecret, "keySecret"); RemoteResource resource = new RemoteResource(); var summary = _mainApiConnection.GetAppVersionContentSummary(_appSecret, versionId); var torrentUrl = _mainApiConnection.GetAppVersionContentTorrentUrl(_appSecret, versionId, keySecret); var urls = _mainApiConnection.GetAppVersionContentUrls(_appSecret, versionId, countryCode); // TODO: Add key secret checking resource.Size = summary.Size; resource.HashCode = summary.HashCode; resource.ChunksData = ConvertToChunksData(summary.Chunks); resource.TorrentUrls = new[] { torrentUrl.Url }; resource.Urls = urls.Select(u => u.Url).ToArray(); resource.MetaUrls = urls.Select(u => u.MetaUrl).Where(u => u != null).ToArray(); return(resource); }
public RemoteResourceDownloader(string destinationFilePath, string destinationMetaPath, RemoteResource resource, bool useTorrents) : this(destinationFilePath, destinationMetaPath, resource, useTorrents, CreateDefaultHttpDownloader, CreateDefaultChunkedHttpDownloader, CreateDefaultTorrentDownloader) { }
private static ITorrentDownloader CreateDefaultTorrentDownloader(string destinationFilePath, RemoteResource resource, int timeout) { return(new TorrentDownloader(destinationFilePath, resource, timeout)); }
private static IChunkedHttpDownloader CreateDefaultChunkedHttpDownloader(string destinationFilePath, RemoteResource resource, int timeout) { return(new ChunkedHttpDownloader(destinationFilePath, resource, timeout)); }