Skip to content

Commit

Permalink
Merge pull request #138 from MaximumADHD/channels
Browse files Browse the repository at this point in the history
Channel Support
  • Loading branch information
MaximumADHD authored Aug 24, 2022
2 parents c5cfb28 + 31b2419 commit a15ac00
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 146 deletions.
18 changes: 16 additions & 2 deletions ProjectSrc/Bootstrapper/FileManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Runtime.Serialization;
using System.Threading.Tasks;

using RobloxDeployHistory;

namespace RobloxStudioModManager
{
[Serializable]
Expand Down Expand Up @@ -41,16 +43,28 @@ private FileManifest(string data, bool remapExtraContent = false)
else if (remapExtraContent && path.StartsWith("ExtraContent", Program.StringFormat))
path = path.Replace("ExtraContent", "content");

// ~~ AWFUL TEMPORARY HACK. ~~
//
// This is necessary because SourceSansPro gets incorrectly listed in the root directory,
// but also MUST be extracted to both 'StudioFonts/' and 'content/fonts/', so I need to
// make sure it unambiguously extracts to the correct locations.

if (path.EndsWith(".ttf") && !path.Contains("\\"))
path = "StudioFonts\\" + path;

Add(path, signature);
}
}

RawData = data;
}

public static async Task<FileManifest> Get(string branch, string versionGuid, bool remapExtraContent = false)
public static async Task<FileManifest> Get(ClientVersionInfo info, bool remapExtraContent = false)
{
string fileManifestUrl = $"https://s3.amazonaws.com/setup.{branch}.com/{versionGuid}-rbxManifest.txt";
Channel channel = info.Channel;
string versionGuid = info.VersionGuid;

string fileManifestUrl = $"https://setup.rbxcdn.com/channel/{channel}/{versionGuid}-rbxManifest.txt";
string fileManifestData;

using (WebClient http = new WebClient())
Expand Down
9 changes: 7 additions & 2 deletions ProjectSrc/Bootstrapper/PackageManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Net;
using System.Threading.Tasks;

using RobloxDeployHistory;

namespace RobloxStudioModManager
{
internal class PackageManifest : List<Package>
Expand Down Expand Up @@ -68,9 +70,12 @@ private PackageManifest(string data)
RawData = data;
}

public static async Task<PackageManifest> Get(string branch, string versionGuid)
public static async Task<PackageManifest> Get(ClientVersionInfo info)
{
string pkgManifestUrl = $"https://s3.amazonaws.com/setup.{branch}.com/{versionGuid}-rbxPkgManifest.txt";
Channel channel = info.Channel;
string versionGuid = info.VersionGuid;

string pkgManifestUrl = $"https://setup.rbxcdn.com/channel/{channel}/{versionGuid}-rbxPkgManifest.txt";
string pkgManifestData;

using (WebClient http = new WebClient())
Expand Down
71 changes: 26 additions & 45 deletions ProjectSrc/Bootstrapper/StudioBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class StudioBootstrapper
private readonly Dictionary<string, string> fileRegistry;
private readonly Dictionary<string, PackageState> pkgRegistry;

private Dictionary<string, string[]> bySignature;
private Dictionary<string, string> newManifestEntries;
private HashSet<string> writtenFiles;
private FileManifest fileManifest;
Expand Down Expand Up @@ -110,7 +111,7 @@ private set
}
}

public string Branch { get; set; } = "roblox";
public Channel Channel { get; set; } = "zLive";
public string OverrideStudioDirectory { get; set; } = "";

public bool CanShutdownStudio { get; set; } = true;
Expand All @@ -129,15 +130,6 @@ public StudioBootstrapper(IBootstrapperState state = null)
else
mainState = state;

if (!mainState.DeprecateMD5)
{
// The manifest registry needs to be reset.
mainState.VersionData = new VersionManifest();
mainState.PackageManifest.Clear();
mainState.FileManifest.Clear();
mainState.DeprecateMD5 = true;
}

versionRegistry = mainState.VersionData;
pkgRegistry = mainState.PackageManifest;
fileRegistry = mainState.FileManifest;
Expand Down Expand Up @@ -338,13 +330,13 @@ private void deleteUnusedFiles()
}
}

public static async Task<ClientVersionInfo> GetTargetVersionInfo(string branch, string targetVersion, VersionManifest versionRegistry = null)
public static async Task<ClientVersionInfo> GetTargetVersionInfo(Channel channel, string targetVersion, VersionManifest versionRegistry = null)
{
if (versionRegistry == null)
versionRegistry = Program.State.VersionData;

var logData = await StudioDeployLogs
.Get(branch)
.Get(channel)
.ConfigureAwait(false);

HashSet<DeployLog> targets;
Expand All @@ -360,29 +352,29 @@ public static async Task<ClientVersionInfo> GetTargetVersionInfo(string branch,

if (target == null)
{
var result = GetCurrentVersionInfo(branch, versionRegistry);
var result = GetCurrentVersionInfo(channel, versionRegistry);
return await result.ConfigureAwait(false);
}

return new ClientVersionInfo(target);
}

public static async Task<ClientVersionInfo> GetCurrentVersionInfo(string branch, VersionManifest versionRegistry = null, string targetVersion = "")
public static async Task<ClientVersionInfo> GetCurrentVersionInfo(Channel channel, VersionManifest versionRegistry = null, string targetVersion = "")
{
if (versionRegistry == null)
versionRegistry = Program.State.VersionData;

if (!string.IsNullOrEmpty(targetVersion))
{
var result = GetTargetVersionInfo(branch, targetVersion, versionRegistry);
var result = GetTargetVersionInfo(channel, targetVersion, versionRegistry);
return await result.ConfigureAwait(false);
}

bool is64Bit = Environment.Is64BitOperatingSystem;
ClientVersionInfo info;

var logData = await StudioDeployLogs
.Get(branch)
.Get(channel)
.ConfigureAwait(false);

DeployLog build_x86 = logData.CurrentLogs_x86.Last();
Expand Down Expand Up @@ -440,7 +432,7 @@ private async Task<bool> packageExists(Package package)
echo($"Verifying availability of: {package.Name}");

string pkgName = package.Name;
var zipFileUrl = new Uri($"https://s3.amazonaws.com/setup.{Branch}.com/{buildVersion}-{pkgName}");
var zipFileUrl = new Uri($"https://setup.rbxcdn.com/channel/{Channel}/{buildVersion}-{pkgName}");

var request = WebRequest.Create(zipFileUrl) as HttpWebRequest;
request.Headers.Set("UserAgent", UserAgent);
Expand All @@ -461,7 +453,7 @@ private async Task<byte[]> installPackage(Package package)
{
byte[] result = null;
string pkgName = package.Name;
string zipFileUrl = $"https://s3.amazonaws.com/setup.{Branch}.com/{buildVersion}-{pkgName}";
string zipFileUrl = $"https://setup.rbxcdn.com/channel/{Channel}/{buildVersion}-{pkgName}";

using (var localHttp = new WebClient())
{
Expand Down Expand Up @@ -533,9 +525,6 @@ private void extractPackage(Package package)
.Where(name => !name.EndsWith("/", Program.StringFormat))
.Count();

lock (ProgressLock)
MaxProgress += numFiles;

string localRootDir = null;

if (KnownRoots.ContainsKey(pkgName))
Expand All @@ -555,12 +544,7 @@ private void extractPackage(Package package)
skip = true;

if (skip)
{
lock (ProgressLock)
Progress++;

continue;
}

string newFileSig = null;
string entryPath = entry.FullName.Replace('/', '\\');
Expand Down Expand Up @@ -601,11 +585,8 @@ private void extractPackage(Package package)
newFileSig = computeSignature(entry);

// Now check what files this signature corresponds with.
var files = fileManifest
.Where(pair => pair.Value == newFileSig)
.Select(pair => pair.Key);

if (files.Any())

if (bySignature.TryGetValue(newFileSig, out var files))
{
foreach (string file in files)
{
Expand Down Expand Up @@ -687,9 +668,6 @@ private void WritePackageFile(string studioDir, string pkgName, string file, str

if (oldFileSig == newFileSig)
{
lock (ProgressLock)
Progress++;

return;
}
}
Expand All @@ -714,9 +692,6 @@ private void WritePackageFile(string studioDir, string pkgName, string file, str
echo($"FILE WRITE FAILED: {filePath} (This build may not run as expected!)");
}

lock (ProgressLock)
Progress++;

writtenFiles.Add(filePath);
}

Expand Down Expand Up @@ -818,17 +793,16 @@ public async Task<bool> Bootstrap(string targetVersion = "")

string baseConfigUrl = $"https://raw.githubusercontent.com/{RepoOwner}/{RepoName}/{RepoBranch}/Config/";
string currentVersion = versionRegistry.VersionGuid;
string currentBranch;
string currentChannel;

if (mainState == Program.State)
currentBranch = mainState.BuildBranch;
currentChannel = mainState.Channel;
else
currentBranch = Branch;
currentChannel = Channel;

var getVersionInfo = GetCurrentVersionInfo(currentBranch, versionRegistry, targetVersion);
var getVersionInfo = GetCurrentVersionInfo(currentChannel, versionRegistry, targetVersion);
ClientVersionInfo versionInfo = await getVersionInfo.ConfigureAwait(true);


string studioDir = GetLocalStudioDirectory();
buildVersion = versionInfo.VersionGuid;

Expand Down Expand Up @@ -890,18 +864,25 @@ public async Task<bool> Bootstrap(string targetVersion = "")
echo("Grabbing package manifest...");

var pkgManifest = await PackageManifest
.Get(Branch, buildVersion)
.Get(versionInfo)
.ConfigureAwait(true);

echo("Grabbing file manifest...");

fileManifest = await FileManifest
.Get(Branch, buildVersion, RemapExtraContent)
.Get(versionInfo, RemapExtraContent)
.ConfigureAwait(true);

var taskQueue = new List<Task>();
writtenFiles = new HashSet<string>();

bySignature =
(from pair in fileManifest
let key = pair.Key
let value = pair.Value
group key by value)
.ToDictionary(group => group.Key, group => group.ToArray());

Progress = 0;
MaxProgress = 0;
ProgressBarStyle = ProgressBarStyle.Continuous;
Expand Down Expand Up @@ -1037,7 +1018,7 @@ await Task
ProgressBarStyle = ProgressBarStyle.Marquee;

if (mainState == Program.State)
mainState.BuildBranch = Branch;
mainState.Channel = Channel;

versionRegistry.Version = versionId;
versionRegistry.VersionGuid = buildVersion;
Expand Down
6 changes: 4 additions & 2 deletions ProjectSrc/Forms/BootstrapperForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Threading.Tasks;
using System.Windows.Forms;

using RobloxDeployHistory;

namespace RobloxStudioModManager
{
public partial class BootstrapperForm : Form
Expand Down Expand Up @@ -37,7 +39,7 @@ public async Task Bootstrap()
await bootstrap.ConfigureAwait(true);
}

public static async Task BringUpToDate(string branch, string expectedVersion, string updateReason)
public static async Task BringUpToDate(Channel channel, string expectedVersion, string updateReason)
{
var versionData = Program.State.VersionData;
string currentVersion = versionData.VersionGuid;
Expand All @@ -62,7 +64,7 @@ public static async Task BringUpToDate(string branch, string expectedVersion, st

if (check == DialogResult.Yes)
{
var bootstrapper = new StudioBootstrapper() { Branch = branch };
var bootstrapper = new StudioBootstrapper() { Channel = channel };

using (var installer = new BootstrapperForm(bootstrapper))
{
Expand Down
Loading

0 comments on commit a15ac00

Please sign in to comment.