public static void Run(DirectoryInfo gamePath, DalamudLoadingOverlay overlay)
        {
            Log.Information("[DUPDATE] Starting...");

            Task.Run(() =>
            {
                try
                {
                    UpdateDalamud(gamePath, overlay);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "[DUPDATE] Update failed...");
                    State = DownloadState.Failed;
                }
            });
        }
Ejemplo n.º 2
0
 public DalamudLauncher(DalamudLoadingOverlay overlay)
 {
     _overlay = overlay;
 }
        private static void UpdateDalamud(DirectoryInfo gamePath, DalamudLoadingOverlay overlay)
        {
            DalamudUpdater.overlay = overlay;

            using var client = new WebClient();

            var doDalamudTest = DalamudSettings.GetSettings().DoDalamudTest;

            // GitHub requires TLS 1.2, we need to hardcode this for Windows 7
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var versionInfoJson = client.DownloadString(DalamudLauncher.REMOTE_BASE + (doDalamudTest ? "stg/" : string.Empty) + "version");

            var remoteVersionInfo = JsonConvert.DeserializeObject <DalamudVersionInfo>(versionInfoJson);

            var addonPath = new DirectoryInfo(Path.Combine(Paths.RoamingPath, "addon", "Hooks", remoteVersionInfo.AssemblyVersion));

            AssetDirectory = new DirectoryInfo(Path.Combine(Util.GetRoaming(), "dalamudAssets"));

            try
            {
                if (Repository.Ffxiv.GetVer(gamePath) != remoteVersionInfo.SupportedGameVer)
                {
                    State = DownloadState.Failed;
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[DUPDATE] Could not get game version");
                State = DownloadState.Failed;
            }

            if (!addonPath.Exists)
            {
                Log.Information("[DUPDATE] Not found, redownloading");

                overlay.Dispatcher.Invoke(() => overlay.SetProgress(DalamudLoadingOverlay.DalamudLoadingProgress.Dalamud));
                Download(addonPath, doDalamudTest);

                Log.Information("[DUPDATE] Download OK!");
            }

            try
            {
                overlay.Dispatcher.Invoke(() => overlay.SetProgress(DalamudLoadingOverlay.DalamudLoadingProgress.Assets));

                if (!AssetManager.EnsureAssets(AssetDirectory))
                {
                    Log.Information("[DUPDATE] Assets not ensured, bailing out...");
                    State = DownloadState.Failed;
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[DUPDATE] Asset ensurement error, bailing out...");
                State = DownloadState.Failed;
                return;
            }

            Log.Information("[DUPDATE] All set.");

            Runner = new FileInfo(Path.Combine(addonPath.FullName, "Dalamud.Injector.exe"));

            State = DownloadState.Done;
        }
Ejemplo n.º 4
0
        private static void UpdateDalamud(DirectoryInfo gamePath, DalamudLoadingOverlay overlay)
        {
            using var client = new WebClient();

            var settings = DalamudSettings.GetSettings();

            // GitHub requires TLS 1.2, we need to hardcode this for Windows 7
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var versionInfoJson = client.DownloadString(DalamudLauncher.REMOTE_BASE + (settings.DoDalamudTest ? "stg/" : string.Empty) + "version");

            var remoteVersionInfo = JsonConvert.DeserializeObject <DalamudVersionInfo>(versionInfoJson);

            var addonPath    = new DirectoryInfo(Path.Combine(Paths.RoamingPath, "addon", "Hooks", remoteVersionInfo.AssemblyVersion));
            var runtimePath  = new DirectoryInfo(Path.Combine(Paths.RoamingPath, "runtime"));
            var runtimePaths = new DirectoryInfo[]
            {
                new DirectoryInfo(Path.Combine(runtimePath.FullName, "host", "fxr", remoteVersionInfo.RuntimeVersion)),
                new DirectoryInfo(Path.Combine(runtimePath.FullName, "shared", "Microsoft.NETCore.App", remoteVersionInfo.RuntimeVersion)),
                new DirectoryInfo(Path.Combine(runtimePath.FullName, "shared", "Microsoft.WindowsDesktop.App", remoteVersionInfo.RuntimeVersion)),
            };

            AssetDirectory = new DirectoryInfo(Path.Combine(Paths.RoamingPath, "dalamudAssets"));

            Log.Information("[DUPDATE] Now starting for Dalamud {0}", remoteVersionInfo.AssemblyVersion);

            if (!addonPath.Exists || !IsIntegrity(addonPath))
            {
                Log.Information("[DUPDATE] Not found, redownloading");

                SetOverlayProgress(DalamudLoadingOverlay.DalamudLoadingProgress.Dalamud);

                try
                {
                    Download(addonPath, settings.DoDalamudTest);

                    // This is a good indicator that we should clear the UID cache
                    UniqueIdCache.Instance.Reset();
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "[DUPDATE] Could not download update package.");

                    State = DownloadState.NoIntegrity;
                    return;
                }

                Log.Information("[DUPDATE] Download OK!");
            }

            if (remoteVersionInfo.RuntimeRequired || settings.DoDalamudRuntime)
            {
                Log.Information("[DUPDATE] Now starting for .NET Runtime {0}", remoteVersionInfo.RuntimeVersion);

                if (runtimePaths.Any(p => !p.Exists))
                {
                    Log.Information("[DUPDATE] Not found, redownloading");

                    SetOverlayProgress(DalamudLoadingOverlay.DalamudLoadingProgress.Runtime);

                    try
                    {
                        DownloadRuntime(runtimePath, remoteVersionInfo.RuntimeVersion);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "[DUPDATE] Could not download update package.");

                        State = DownloadState.Failed;
                        return;
                    }

                    Log.Information("[DUPDATE] Download OK!");
                }
            }

            try
            {
                SetOverlayProgress(DalamudLoadingOverlay.DalamudLoadingProgress.Assets);

                if (!AssetManager.EnsureAssets(AssetDirectory))
                {
                    Log.Information("[DUPDATE] Assets not ensured, bailing out...");
                    State = DownloadState.Failed;
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "[DUPDATE] Asset ensurement error, bailing out...");
                State = DownloadState.Failed;
                return;
            }

            if (!IsIntegrity(addonPath))
            {
                Log.Error("[DUPDATE] Integrity check failed.");

                State = DownloadState.NoIntegrity;
                return;
            }

            WriteVersionJson(addonPath, versionInfoJson);

            Log.Information("[DUPDATE] All set for " + remoteVersionInfo.SupportedGameVer);

            Runner = new FileInfo(Path.Combine(addonPath.FullName, "Dalamud.Injector.exe"));

            State = DownloadState.Done;
        }