private static void internalLoadManifest(bool forceLocal = false, bool overrideThrottling = false)
        {
            if (File.Exists(ManifestLocation) && (forceLocal || (!OnlineContent.CanFetchContentThrottleCheck() && !overrideThrottling))) //Force local, or we can't online check and cannot override throttle
            {
                LoadManifestFromDisk(ManifestLocation);
                return;
            }

            var shouldNotFetch = forceLocal || (!overrideThrottling && !OnlineContent.CanFetchContentThrottleCheck()) && File.Exists(ManifestLocation);

            if (!shouldNotFetch) //this cannot be triggered if forceLocal is true
            {
                Log.Information(@"Fetching ASI manifest from online source");
                var onlineManifest = OnlineContent.FetchRemoteString(@"https://me3tweaks.com/mods/asi/getmanifest?AllGames=1");
                onlineManifest = onlineManifest.Trim();
                try
                {
                    File.WriteAllText(StagedManifestLocation, onlineManifest);
                }
                catch (Exception e)
                {
                    Log.Error(@"Error writing cached ASI manifest to disk: " + e.Message);
                }

                try
                {
                    ParseManifest(onlineManifest, true);
                }
                catch (Exception e)
                {
                    Log.Error(@"Error parsing online manifest: " + e.Message);
                    internalLoadManifest(true); //force local load instead
                }
            }
            else if (File.Exists(ManifestLocation))
            {
                Log.Information(@"Loading ASI local manifest");
                LoadManifestFromDisk(ManifestLocation, false);
            }
            else
            {
                //can't get manifest or local manifest.
                //Todo: some sort of handling here as we are running in panel startup
                Log.Error(@"Cannot load ASI manifest: Could not fetch online manifest and no local manifest exists");
            }
        }
Exemple #2
0
        private static void internalLoadManifest(List <ASIGame> games, Action <object> selectionStateUpdateCallback = null)
        {
            using WebClient wc = new WebClient();
            var onlineManifest = OnlineContent.FetchRemoteString(@"https://me3tweaks.com/mods/asi/getmanifest?AllGames=1");

            if (onlineManifest != null)
            {
                File.WriteAllText(StagedManifestLocation, onlineManifest);
                ParseManifest(StagedManifestLocation, games, true, selectionStateUpdateCallback);
            }
            else if (File.Exists(ManifestLocation))
            {
                Log.Information(@"Loading ASI local manifest");
                ParseManifest(ManifestLocation, games, false, selectionStateUpdateCallback);
            }
            else
            {
                //can't get manifest or local manifest.
                //Todo: some sort of handling here as we are running in panel startup
            }
        }
Exemple #3
0
        private static void internalLoadManifest(List <ASIGame> games, Action <object> selectionStateUpdateCallback = null, bool forceLocal = false)
        {
            using WebClient wc = new WebClient();
            var onlineManifest = forceLocal ? null : OnlineContent.FetchRemoteString(@"https://me3tweaks.com/mods/asi/getmanifest?AllGames=1");

            if (onlineManifest != null) //this cannot be triggered if forceLocal is true
            {
                try
                {
                    File.WriteAllText(StagedManifestLocation, onlineManifest);
                }
                catch (Exception e)
                {
                    Log.Error(@"Error writing cached ASI manifest to disk: " + e.Message);
                }

                try
                {
                    ParseManifest(onlineManifest, games, true, selectionStateUpdateCallback);
                }
                catch (Exception e)
                {
                    Log.Error(@"Error parsing online manifest: " + e.Message);
                    internalLoadManifest(games, selectionStateUpdateCallback, true); //force local load instead
                }
            }
            else if (File.Exists(ManifestLocation))
            {
                Log.Information(@"Loading ASI local manifest");
                LoadManifestFromDisk(ManifestLocation, games, false, selectionStateUpdateCallback);
            }
            else
            {
                //can't get manifest or local manifest.
                //Todo: some sort of handling here as we are running in panel startup
                Log.Error(@"Cannot load ASI manifest: Could not fetch online manifest and no local manifest exists");
            }
        }