Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Fantome.Libraries.RADS
6 changes: 5 additions & 1 deletion LeagueDownloader/Content/RemoteAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ public class RemoteAsset
public bool IsCompressed { get; private set; }
public AssetContent AssetContent { get; private set; }

public RemoteAsset(ReleaseManifestFileEntry fileEntry, string projectURL)
public RemoteAsset(ReleaseManifestFileEntry fileEntry, string projectURL, bool? forceCompressionOpt)
{
this.FileEntry = fileEntry;
this.StringVersion = Utilities.GetReleaseString(fileEntry.Version);
this.FileFullPath = fileEntry.GetFullPath();
this.IsCompressed = this.FileEntry.SizeCompressed > 0;
if (forceCompressionOpt is bool forceCompression)
{
this.IsCompressed = forceCompression;
}

string[] fileParts = this.FileFullPath.Split('/');
for (int i = 0; i < fileParts.Length; i++)
Expand Down
5 changes: 3 additions & 2 deletions LeagueDownloader/LeagueDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=2.2.1.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.2.1\lib\net45\CommandLine.dll</HintPath>
<Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Iconic.Zlib.Netstandard, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Iconic.Zlib.Netstandard.1.0.0\lib\netstandard1.3\Iconic.Zlib.Netstandard.dll</HintPath>
Expand Down Expand Up @@ -126,6 +126,7 @@
<Compile Include="Content\RemoteAsset.cs" />
<Compile Include="Project\ProjectRelease.cs" />
<Compile Include="Project\ProjectReleaseFileInstaller.cs" />
<Compile Include="Project\ProjectReleaseGarenaFileInstaller.cs" />
<Compile Include="Project\ProjectReleaseInstallation.cs" />
<Compile Include="Project\ProjectReleaseArchivedFileInstaller.cs" />
<Compile Include="Project\ProjectReleaseDeployedFileInstaller.cs" />
Expand Down
22 changes: 16 additions & 6 deletions LeagueDownloader/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommandLine;
using static Fantome.Libraries.RADS.IO.ReleaseManifest.ReleaseManifestFile;

namespace LeagueDownloader
{
Expand All @@ -11,6 +12,9 @@ abstract class CommonInstallOptions

[Option('u', "cdn-url", Default = Constants.DefaultCDN, Required = false, HelpText = "CDN url to use.")]
public string CDNBaseURL { get; set; }

[Option('c', "compression", Default = null, Required = false, HelpText = "Force .compresed files off or on")]
public bool? ForceCompression { get; set; }
}

[Verb("solution", HelpText = "Install a complete solution.")]
Expand All @@ -26,7 +30,7 @@ class SolutionOptions : CommonInstallOptions
public string Localization { get; set; }

[Option('d', "deploy-mode", Required = false, Default = null, HelpText = "Forced deploy mode.")]
public uint? DeployMode { get; set; }
public DeployMode? DeployMode { get; set; }
}

[Verb("project", HelpText = "Install a project.")]
Expand All @@ -39,7 +43,7 @@ class ProjectOptions : CommonInstallOptions
public string Version { get; set; }

[Option('d', "deploy-mode", Required = false, Default = null, HelpText = "Forced deploy mode.")]
public uint? DeployMode { get; set; }
public DeployMode? DeployMode { get; set; }
}

abstract class CommonSelectionOptions
Expand Down Expand Up @@ -74,6 +78,9 @@ class DownloadOptions : CommonListOptions

[Option("save-manifest", Required = false, Default = false, HelpText = "Save the downloaded release manifest.")]
public bool SaveManifest { get; set; }

[Option('c', "compression", Default = null, Required = false, HelpText = "Force .compresed files off or on")]
public bool? ForceCompression { get; set; }
}

[Verb("range-download", HelpText = "Download files in a range of revisions.")]
Expand All @@ -93,6 +100,9 @@ class RangeDownloadOptions : CommonSelectionOptions

[Option("save-manifest", Required = false, Default = false, HelpText = "Save the downloaded release manifest.")]
public bool SaveManifest { get; set; }

[Option('c', "compression", Default = null, Required = false, HelpText = "Force .compresed files off or on")]
public bool? ForceCompression { get; set; }
}

static void Main(string[] args)
Expand All @@ -110,14 +120,14 @@ static void Main(string[] args)
static int InstallSolution(SolutionOptions opts)
{
RADSInteractor radsInteractor = new RADSInteractor(opts.CDNBaseURL);
radsInteractor.InstallSolution(opts.OutputFolder, opts.Name, opts.Version, opts.Localization, opts.DeployMode);
radsInteractor.InstallSolution(opts.OutputFolder, opts.Name, opts.Version, opts.Localization, opts.DeployMode, opts.ForceCompression);
return 1;
}

static int InstallProject(ProjectOptions opts)
{
RADSInteractor radsInteractor = new RADSInteractor(opts.CDNBaseURL);
radsInteractor.InstallProject(opts.OutputFolder, opts.Name, opts.Version, opts.DeployMode);
radsInteractor.InstallProject(opts.OutputFolder, opts.Name, opts.Version, opts.ForceCompression, opts.DeployMode);
return 1;
}

Expand All @@ -131,14 +141,14 @@ static int ListFiles(ListOptions opts)
static int DownloadFiles(DownloadOptions opts)
{
RADSInteractor radsInteractor = new RADSInteractor(opts.CDNBaseURL);
radsInteractor.DownloadFiles(opts.OutputFolder, opts.ProjectName, opts.ProjectVersion, opts.Filter, opts.FilesRevision, opts.SaveManifest);
radsInteractor.DownloadFiles(opts.OutputFolder, opts.ProjectName, opts.ProjectVersion, opts.ForceCompression, opts.Filter, opts.FilesRevision, opts.SaveManifest);
return 1;
}

static int RangeDownloadFiles(RangeDownloadOptions opts)
{
RADSInteractor radsInteractor = new RADSInteractor(opts.CDNBaseURL);
radsInteractor.RangeDownloadFiles(opts.OutputFolder, opts.ProjectName, opts.IgnoreOlderFiles, opts.Filter, opts.StartRevision, opts.EndRevision, opts.SaveManifest);
radsInteractor.RangeDownloadFiles(opts.OutputFolder, opts.ProjectName, opts.ForceCompression, opts.IgnoreOlderFiles, opts.Filter, opts.StartRevision, opts.EndRevision, opts.SaveManifest);
return 1;
}
}
Expand Down
6 changes: 4 additions & 2 deletions LeagueDownloader/Project/ProjectRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ public class ProjectRelease
public ReleaseManifestFile ReleaseManifest { get; private set; }
public string ProjectBaseURL { get; private set; }
public string ReleaseBaseURL { get; private set; }
public bool? ForceCompression { get; private set; }

public ProjectRelease(string name, string version, string leagueCDNBaseURL)
public ProjectRelease(string name, string version, string leagueCDNBaseURL, bool? forceCompression)
{
this.Name = name;
this.Version = version;
this.LeagueCDNBaseURL = leagueCDNBaseURL;
this.ProjectBaseURL = String.Format("{0}/projects/{1}", this.LeagueCDNBaseURL, this.Name);
this.ReleaseBaseURL = String.Format("{0}/releases/{1}", this.ProjectBaseURL, this.Version);
this.ReleaseManifest = new ReleaseManifestFile(new WebClient().OpenRead(this.ReleaseBaseURL + "/releasemanifest"));
this.ForceCompression = forceCompression;
}

public List<ReleaseManifestFileEntry> EnumerateFiles()
Expand All @@ -42,7 +44,7 @@ private static void EnumerateManifestFolderFiles(ReleaseManifestFolderEntry fold

public RemoteAsset GetRemoteAsset(ReleaseManifestFileEntry fileEntry)
{
return new RemoteAsset(fileEntry, this.ProjectBaseURL);
return new RemoteAsset(fileEntry, this.ProjectBaseURL, ForceCompression);
}
}
}
62 changes: 44 additions & 18 deletions LeagueDownloader/Project/ProjectReleaseInstallation.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
using System;
using System.IO;
using LeagueDownloader.Content;
using static Fantome.Libraries.RADS.IO.ReleaseManifest.ReleaseManifestFile;
using static Fantome.Libraries.RADS.IO.ReleaseManifest.ReleaseManifestFile.DeployMode;

namespace LeagueDownloader.Project
{
public class ProjectReleaseInstallation : IDisposable
{
public DeployMode? OverrideDeployMode { get; private set; }
public ProjectRelease ProjectRelease { get; private set; }
public string ProjectDirectory { get; private set; }
public string ProjectReleaseDirectory { get; private set; }
public ProjectReleaseArchivedFileInstaller ProjectReleaseArchivedFileInstaller { get; private set; }
public ProjectReleaseManagedFileInstaller ProjectReleaseManagedFileInstaller { get; private set; }
public ProjectReleaseDeployedFileInstaller ProjectReleaseDeployedFileInstaller { get; private set; }
public ProjectReleaseGarenaFileInstaller ProjectReleaseGarenaFileInstaller { get; private set; }

public ProjectReleaseInstallation(ProjectRelease projectRelease, string installationDirectory, string solutionName = null, string solutionVersion = null)
public ProjectReleaseInstallation(ProjectRelease projectRelease, string installationDirectory, string solutionName = null, string solutionVersion = null, DeployMode? deployMode = null)
{
this.ProjectRelease = projectRelease;
this.ProjectDirectory = String.Format("{0}/RADS/projects/{1}", installationDirectory, projectRelease.Name);
this.ProjectReleaseDirectory = String.Format("{0}/releases/{1}", this.ProjectDirectory, projectRelease.Version);
this.OverrideDeployMode = deployMode;
if (OverrideDeployMode != DeployMode.Garena)
{
this.ProjectRelease = projectRelease;
this.ProjectDirectory = String.Format("{0}/RADS/projects/{1}", installationDirectory, projectRelease.Name);
this.ProjectReleaseDirectory = String.Format("{0}/releases/{1}", this.ProjectDirectory, projectRelease.Version);

Directory.CreateDirectory(this.ProjectReleaseDirectory);
this.ProjectRelease.ReleaseManifest.Write(this.ProjectReleaseDirectory + "/releasemanifest");
Directory.CreateDirectory(this.ProjectReleaseDirectory);
this.ProjectRelease.ReleaseManifest.Write(this.ProjectReleaseDirectory + "/releasemanifest");

string solutionReleaseDirectory = null;
if (solutionName != null && solutionVersion != null)
{
solutionReleaseDirectory = String.Format("{0}/RADS/solutions/{1}/releases/{2}", installationDirectory, solutionName, solutionVersion);
}
string solutionReleaseDirectory = null;
if (solutionName != null && solutionVersion != null)
{
solutionReleaseDirectory = String.Format("{0}/RADS/solutions/{1}/releases/{2}", installationDirectory, solutionName, solutionVersion);
}

this.ProjectReleaseArchivedFileInstaller = new ProjectReleaseArchivedFileInstaller(this.ProjectDirectory);
this.ProjectReleaseManagedFileInstaller = new ProjectReleaseManagedFileInstaller(this.ProjectDirectory);
this.ProjectReleaseDeployedFileInstaller = new ProjectReleaseDeployedFileInstaller(this.ProjectReleaseDirectory, solutionReleaseDirectory);
this.ProjectReleaseArchivedFileInstaller = new ProjectReleaseArchivedFileInstaller(this.ProjectDirectory);
this.ProjectReleaseManagedFileInstaller = new ProjectReleaseManagedFileInstaller(this.ProjectDirectory);
this.ProjectReleaseDeployedFileInstaller = new ProjectReleaseDeployedFileInstaller(this.ProjectReleaseDirectory, solutionReleaseDirectory);
}
this.ProjectReleaseGarenaFileInstaller = new ProjectReleaseGarenaFileInstaller(installationDirectory);
}

public void InstallFile(RemoteAsset remoteAsset)
public void InstallFile(RemoteAsset remoteAsset, DeployMode deployMode)
{
ProjectReleaseFileInstaller fileInstaller;
switch (remoteAsset.FileEntry.DeployMode)
switch (deployMode)
{
case Garena:
fileInstaller = this.ProjectReleaseGarenaFileInstaller;
break;
case RAFCompressed:
case RAFRaw:
fileInstaller = this.ProjectReleaseArchivedFileInstaller;
Expand All @@ -56,10 +67,25 @@ public void InstallFile(RemoteAsset remoteAsset)
fileInstaller.InstallFile(remoteAsset);
}

public void InstallFile(RemoteAsset remoteAsset)
{
if (OverrideDeployMode is DeployMode deployMode)
{
InstallFile(remoteAsset, deployMode);
}
else
{
InstallFile(remoteAsset, remoteAsset.FileEntry.DeployMode);
}
}

public void Dispose()
{
this.ProjectReleaseArchivedFileInstaller.Dispose();
File.Create(ProjectReleaseDirectory + "/S_OK").Close();
if (OverrideDeployMode != DeployMode.Garena)
{
this.ProjectReleaseArchivedFileInstaller.Dispose();
File.Create(ProjectReleaseDirectory + "/S_OK").Close();
}
}
}
}
24 changes: 12 additions & 12 deletions LeagueDownloader/RADSInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using LeagueDownloader.Project;
using LeagueDownloader.Content;
using Fantome.Libraries.RADS.IO.SolutionManifest;
using static Fantome.Libraries.RADS.IO.ReleaseManifest.ReleaseManifestFile;

namespace LeagueDownloader
{
Expand All @@ -24,30 +25,29 @@ public RADSInteractor(string cdnBaseURL)
this.LeagueCDNBaseURL = cdnBaseURL;
}

public void InstallSolution(string directory, string solutionName, string solutionVersion, string localization, uint? deployMode)
public void InstallSolution(string directory, string solutionName, string solutionVersion, string localization, DeployMode? deployMode, bool? forceCompression)
{
if (String.Equals(solutionVersion, Constants.LatestVersionString))
solutionVersion = GetLatestSolutionRelease(solutionName);

Console.WriteLine("Downloading solution manifest for release {0}", solutionVersion);
SolutionRelease solutionRelease = new SolutionRelease(solutionName, solutionVersion, this.LeagueCDNBaseURL);

using (SolutionReleaseInstallation solutionReleaseInstallation = solutionRelease.CreateInstallation(directory, localization))
using (SolutionReleaseInstallation solutionReleaseInstallation = solutionRelease.CreateInstallation(directory, localization, deployMode))
{
foreach (SolutionManifestProjectEntry project in solutionReleaseInstallation.LocalizedEntry.Projects)
InstallProject(directory, project.Name, project.Version, deployMode, solutionName, solutionVersion);
InstallProject(directory, project.Name, project.Version, forceCompression, deployMode, solutionName, solutionVersion);
}
}

public void InstallProject(string directory, string projectName, string projectVersion, uint? deployMode, string solutionName = null, string solutionVersion = null)
public void InstallProject(string directory, string projectName, string projectVersion, bool? forceCompression, DeployMode? deployMode, string solutionName = null, string solutionVersion = null)
{
if (String.Equals(projectVersion, Constants.LatestVersionString))
projectVersion = GetLatestProjectRelease(projectName);

Console.WriteLine("Downloading manifest for project {0}, release {1}...", projectName, projectVersion);
ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL);
ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL, forceCompression);

using (ProjectReleaseInstallation installation = new ProjectReleaseInstallation(projectRelease, directory, solutionName, solutionVersion))
using (ProjectReleaseInstallation installation = new ProjectReleaseInstallation(projectRelease, directory, solutionName, solutionVersion, deployMode))
{
foreach (ReleaseManifestFileEntry file in projectRelease.EnumerateFiles())
{
Expand All @@ -74,19 +74,19 @@ public void ListFiles(string projectName, string projectVersion, string filter =
if (String.Equals(projectVersion, Constants.LatestVersionString))
projectVersion = GetLatestProjectRelease(projectName);

ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL);
ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL, null);

List<ReleaseManifestFileEntry> files = FilterFiles(projectRelease.EnumerateFiles(), filter, filesRevision);
foreach (ReleaseManifestFileEntry file in files)
Console.WriteLine("{0}/{1}", GetReleaseString(file.Version), file.GetFullPath());
}

public void DownloadFiles(string directory, string projectName, string projectVersion, string filter = null, string filesRevision = null, bool saveManifest = false)
public void DownloadFiles(string directory, string projectName, string projectVersion, bool? forceCompression, string filter = null, string filesRevision = null, bool saveManifest = false)
{
if (String.Equals(projectVersion, Constants.LatestVersionString))
projectVersion = GetLatestProjectRelease(projectName);

ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL);
ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL, forceCompression);
if (saveManifest)
{
string manifestPath = String.Format("{0}/{1}/releases/{2}/releasemanifest", directory, projectName, projectVersion);
Expand All @@ -104,7 +104,7 @@ public void DownloadFiles(string directory, string projectName, string projectVe
}
}

public void RangeDownloadFiles(string directory, string projectName, bool ignoreOlderFiles = false, string filter = null, string startRevision = null, string endRevision = null, bool saveManifest = false)
public void RangeDownloadFiles(string directory, string projectName, bool? forceCompression, 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);
Expand All @@ -121,7 +121,7 @@ public void RangeDownloadFiles(string directory, string projectName, bool ignore
ProjectRelease projectRelease;
try
{
projectRelease = new ProjectRelease(projectName, releaseString, this.LeagueCDNBaseURL);
projectRelease = new ProjectRelease(projectName, releaseString, this.LeagueCDNBaseURL, forceCompression);
} catch (Exception)
{
Console.WriteLine("Error getting manifest for release " + releaseString);
Expand Down
Loading