diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-05 18:06:21 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-12-05 18:06:21 +0200 |
| commit | 9259bc36791a7084ae33bcf0a698101ddb24d28f (patch) | |
| tree | 81f41efe302cf8381e282315ce209baf71d78d0f /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate | |
| parent | 959b48659a8ad212add5927a43da7f5593c54249 (diff) | |
| download | Tango-9259bc36791a7084ae33bcf0a698101ddb24d28f.tar.gz Tango-9259bc36791a7084ae33bcf0a698101ddb24d28f.zip | |
Integrated CDN downloads to PPC and MS.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 8642c089f..333fb261d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -329,24 +329,32 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log("Downloading software package..."); - long fileSize = 0; UpdateProgress("Downloading software package", "Downloading...", false); - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => + AutoFileDownloader downloader = new AutoFileDownloader(update_response.BlobAddress, update_response.CdnAddress, tempFile); + await downloader.ResolveMode(); + + if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) { - UpdateProgress("Downloading software package", "Downloading...", false, current, fileSize); - })) + LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); + } + else { - LogManager.Log($"Connecting to storage blob with address {update_response.BlobAddress}"); - CloudBlockBlob blob = new CloudBlockBlob(new Uri(update_response.BlobAddress)); - LogManager.Log("Fetching blob attributes..."); - blob.FetchAttributes(); - fileSize = blob.Properties.Length; - LogManager.Log("Download size: " + fileSize + " bytes."); - LogManager.Log("Starting blob download..."); - blob.DownloadToStream(fs); + LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); } + downloader.Progress += (x, e) => + { + UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); + }; + + var size = await downloader.GetFileSize(); + LogManager.Log("Download size: " + size + " bytes."); + LogManager.Log("Starting file download..."); + await downloader.Download(); + + downloader.Dispose(); + UpdateProgress("Downloading software package", "Extracting package..."); LogManager.Log("Extracting downloaded zip file..."); |
