protected override void DownloadVersionCore(string latestVersion, string target, PaketHashFile hashfile) { var url = String.Format(Constants.PaketExeDownloadUrlTemplate, latestVersion); ConsoleImpl.WriteInfo("Starting download from {0}", url); var tmpFile = BootstrapperHelper.GetTempFile("paket"); WebRequestProxy.DownloadFile(url, tmpFile); if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashfile, latestVersion, tmpFile)) { ConsoleImpl.WriteWarning("Hash of downloaded paket.exe is invalid, retrying once"); WebRequestProxy.DownloadFile(url, tmpFile); if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashfile, latestVersion, tmpFile)) { ConsoleImpl.WriteWarning("Hash of downloaded paket.exe still invalid (Using the file anyway)"); } else { ConsoleImpl.WriteTrace("Hash of downloaded file successfully found in {0}", hashfile); } } else { ConsoleImpl.WriteTrace("Hash of downloaded file successfully found in {0}", hashfile); } FileSystemProxy.CopyFile(tmpFile, target, true); FileSystemProxy.DeleteFile(tmpFile); }
protected override void DownloadVersionCore(string latestVersion, string target, PaketHashFile hashFile) { var cached = Path.Combine(PaketCacheDir, latestVersion, "paket.exe"); if (!FileSystemProxy.FileExists(cached)) { ConsoleImpl.WriteInfo("Version {0} not found in cache.", latestVersion); DownloadAndPlaceInCache(latestVersion, target, cached, hashFile); return; } FileSystemProxy.WaitForFileFinished(cached); if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashFile, latestVersion, cached)) { ConsoleImpl.WriteWarning("Version {0} found in cache but it's hashFile isn't valid.", latestVersion); DownloadAndPlaceInCache(latestVersion, target, cached, hashFile); return; } ConsoleImpl.WriteInfo("Copying version {0} from cache.", latestVersion); ConsoleImpl.WriteTrace("{0} -> {1}", cached, target); using (var targetStream = FileSystemProxy.CreateExclusive(target)) using (var cachedStream = FileSystemProxy.OpenRead(cached)) { cachedStream.CopyTo(targetStream); } }
protected override void DownloadVersionCore(string latestVersion, string target, string hashfile) { var cached = Path.Combine(_paketCacheDir, latestVersion, "paket.exe"); if (!FileSystemProxy.FileExists(cached)) { ConsoleImpl.WriteInfo("Version {0} not found in cache.", latestVersion); DownloadAndPlaceInCache(latestVersion, target, cached, hashfile); return; } if (!BootstrapperHelper.ValidateHash(FileSystemProxy, hashfile, latestVersion, cached)) { ConsoleImpl.WriteWarning("Version {0} found in cache but it's hash isn't valid.", latestVersion); DownloadAndPlaceInCache(latestVersion, target, cached, hashfile); return; } ConsoleImpl.WriteInfo("Copying version {0} from cache.", latestVersion); ConsoleImpl.WriteTrace("{0} -> {1}", cached, target); FileSystemProxy.CopyFile(cached, target, true); }