public void DownloadFiles(string directory, string projectName, string projectVersion, string filter = null, string filesRevision = null, bool saveManifest = false) { if (String.Equals(projectVersion, Constants.LatestVersionString)) { projectVersion = GetLatestProjectRelease(projectName); } using (DownloadSession downloadSession = new DownloadSession(String.Format("Downloading files from project {0} (version {1})", projectName, projectVersion))) { ProjectRelease projectRelease = downloadSession.GetProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL); if (saveManifest) { string manifestPath = String.Format("{0}/{1}/releases/{2}/releasemanifest", directory, projectName, projectVersion); Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); projectRelease.ReleaseManifest.Write(manifestPath); } List <ReleaseManifestFileEntry> files = FilterFiles(projectRelease.EnumerateFiles(), filter, filesRevision); ProjectReleaseFileInstaller fileInstaller = new ProjectReleaseSimpleFileInstaller(directory, projectRelease, false); foreach (ReleaseManifestFileEntry file in files) { downloadSession.RegisterFile(projectRelease.GetRemoteAsset(file), fileInstaller); } downloadSession.DoWork(); } }
public void RangeDownloadFiles(string directory, string projectName, bool ignoreOlderFiles = false, string filter = null, string startRevision = null, string endRevision = null, bool saveManifest = false) { List <string> releases = GetProjectReleases(projectName); uint startRevisionValue = startRevision == null ? 0 : GetReleaseValue(startRevision); uint endRevisionValue = endRevision == null?GetReleaseValue(releases[0]) : GetReleaseValue(endRevision); // Check if specified releases exist startRevisionValue = Math.Max(startRevisionValue, GetReleaseValue(releases.Last())); endRevisionValue = Math.Min(endRevisionValue, GetReleaseValue(releases[0])); using (DownloadSession downloadSession = new DownloadSession(String.Format("Downloading files from project {0} (revisions {1} to {2})", projectName, GetReleaseString(startRevisionValue), GetReleaseString(endRevisionValue)))) { for (uint r = startRevisionValue; r <= endRevisionValue; r++) { downloadSession.ResetRegisteredFiles(); string releaseString = GetReleaseString(r); ProjectRelease projectRelease; try { projectRelease = downloadSession.GetProjectRelease(projectName, releaseString, this.LeagueCDNBaseURL); } catch (Exception) { continue; } if (saveManifest) { string manifestPath = String.Format("{0}/{1}/releases/{2}/releasemanifest", directory, projectName, releaseString); Directory.CreateDirectory(Path.GetDirectoryName(manifestPath)); projectRelease.ReleaseManifest.Write(manifestPath); } List <ReleaseManifestFileEntry> files = FilterFiles(projectRelease.EnumerateFiles(), filter, (r != startRevisionValue || ignoreOlderFiles) ? releaseString : null); if (files.Count > 0) { ProjectReleaseFileInstaller fileInstaller = new ProjectReleaseSimpleFileInstaller(directory, projectRelease, true); foreach (ReleaseManifestFileEntry file in files) { downloadSession.RegisterFile(projectRelease.GetRemoteAsset(file), fileInstaller); } downloadSession.DoWork(); } } } }