コード例 #1
0
        public void Download(CancellationToken cancellationToken)
        {
            Assert.MethodCalledOnlyOnce(ref _downloadHasBeenCalled, "Download");

            if (_resource.HasMetaUrls())
            {
                DebugLogger.Log("Downloading meta data...");

                if (File.Exists(_destinationMetaPath))
                {
                    DebugLogger.Log("Removing previous meta data file: " + _destinationMetaPath);
                    File.Delete(_destinationMetaPath);
                }

                var httpDownloader = CreateDefaultHttpDownloader(_destinationMetaPath, _resource.MetaUrls, 0, HttpDownloaderTimeout);
                httpDownloader.Download(cancellationToken);

                DebugLogger.Log("Meta data downloaded");
            }

            DebugLogger.Log("Downloading content file");

            if (_useTorrents)
            {
                bool downloaded = TryDownloadWithTorrent(cancellationToken);

                if (downloaded)
                {
                    return;
                }
            }

            if (AreChunksAvailable())
            {
                DebugLogger.Log("Chunsk data is available.");
                DownloadWithChunkedHttp(cancellationToken);
            }
            else
            {
                DebugLogger.Log("Chunks data is not available.");
                DownloadWithHttp(cancellationToken);
            }
        }
 private bool AreMetaAvailable()
 {
     return(_resource.HasMetaUrls());
 }