AddNewVersionNumberForMod() public method

Adds the newest information for the given mod.
public AddNewVersionNumberForMod ( IMod p_modMod, IModInfo p_mifNewestInfo ) : void
p_modMod IMod The mod for which to add the newest info.
p_mifNewestInfo IModInfo The newest info to add for the given mod.
return void
Exemplo n.º 1
0
        /// <summary>
        /// Checks for the updated information for the given mods.
        /// </summary>
        /// <param name="p_lstModList">The mods for which to check for updates.</param>
        private void CheckForModListUpdate(List <string> p_lstModList)
        {
            OverallMessage = "Updating mods info: getting online updates...";
            List <IModInfo> mifInfo = new List <IModInfo>();

            try
            {
                //get mod info
                for (int i = 0; i <= m_intRetries; i++)
                {
                    mifInfo = ModRepository.GetModListInfo(p_lstModList);

                    if (mifInfo != null)
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                }

                if (mifInfo != null)
                {
                    ItemProgress           = 0;
                    ItemProgressMaximum    = mifInfo.Count;
                    OverallProgressMaximum = OverallProgress + mifInfo.Count;

                    foreach (ModInfo modUpdate in mifInfo)
                    {
                        if (m_booCancel)
                        {
                            break;
                        }
                        if (OverallProgress < OverallProgressMaximum)
                        {
                            StepOverallProgress();
                        }

                        ItemMessage = modUpdate.ModName;

                        foreach (IMod modMod in m_lstModList.Where(x => (String.IsNullOrEmpty(modUpdate.Id) ? "0" : modUpdate.Id) == x.Id))
                        {
                            if (ItemProgress < ItemProgressMaximum)
                            {
                                StepItemProgress();
                            }
                            modUpdate.CustomCategoryId     = modMod.CustomCategoryId;
                            modUpdate.UpdateWarningEnabled = modMod.UpdateWarningEnabled;
                            AutoUpdater.AddNewVersionNumberForMod(modMod, modUpdate);
                            modMod.UpdateInfo(modUpdate, false);
                            ItemProgress = 0;
                        }
                    }
                }
            }
            catch (RepositoryUnavailableException e)
            {
                Trace.WriteLine(String.Format("ModUpdateCheck FAILED: {0}", e.Message));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="p_objArgs">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] p_objArgs)
        {
            List <string>       ModList    = new List <string>();
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            OverallMessage          = "Updating mods info: setup search...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgress            = 0;
            ItemProgressStepSize    = 1;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = 1;

            OverallProgressMaximum = m_lstModList.Count * 2;
            ItemProgressMaximum    = (m_lstModList.Count > 250) ? 250 : m_lstModList.Count;

            for (int i = 0; i < m_lstModList.Count; i++)
            {
                string modID          = String.Empty;
                Int32  isEndorsed     = 0;
                string strLastVersion = String.Empty;
                ItemMessage = m_lstModList[i].ModName;

                if (m_booCancel)
                {
                    break;
                }

                if (!String.IsNullOrEmpty(m_lstModList[i].Id))
                {
                    modID          = m_lstModList[i].Id;
                    isEndorsed     = m_lstModList[i].IsEndorsed == true ? 1 : (m_lstModList[i].IsEndorsed == false ? -1 : 0);
                    strLastVersion = m_lstModList[i].LastKnownVersion;
                }
                else
                {
                    try
                    {
                        IModInfo mifInfo = ModRepository.GetModInfoForFile(m_lstModList[i].Filename);

                        if (mifInfo != null)
                        {
                            modID = mifInfo.Id;
                            m_lstModList[i].Id = modID;
                            strLastVersion     = m_lstModList[i].LastKnownVersion;
                            AutoUpdater.AddNewVersionNumberForMod(m_lstModList[i], mifInfo);
                        }
                    }
                    catch (RepositoryUnavailableException)
                    {
                        //the repository is not available, so don't bother
                    }
                }

                if (!String.IsNullOrEmpty(modID))
                {
                    if ((m_booOverrideCategorySetup) || (String.IsNullOrEmpty(strLastVersion)))
                    {
                        ModList.Add(String.Format("{0}", modID));
                    }
                    else
                    {
                        ModList.Add(String.Format("{0}|{1}|{2}", modID, m_lstModList[i].HumanReadableVersion, isEndorsed));
                    }
                }

                if (ItemProgress < ItemProgressMaximum)
                {
                    StepItemProgress();
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }

                // Prevents the repository request string from becoming too long.
                if (ModList.Count == 250)
                {
                    CheckForModListUpdate(ModList);
                    ModList.Clear();
                    OverallMessage      = "Updating mods info: setup search...";
                    ItemProgress        = 0;
                    ItemProgressMaximum = (m_lstModList.Count == 250) ? 1 : (m_lstModList.Count - (i + 1));
                }
            }

            if (!m_booCancel && (ModList.Count > 0))
            {
                CheckForModListUpdate(ModList);
            }

            m_lstModList.Clear();

            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks for the updated information for the given mods.
        /// </summary>
        /// <param name="p_lstModList">The mods for which to check for updates.</param>
        private string CheckForModListUpdate(List <string> p_lstModList, List <IMod> p_lstModCheck)
        {
            if (m_booMissingDownloadId != false)
            {
                OverallMessage = "Updating mods info: retrieving download ids..";
            }
            else
            {
                OverallMessage = "Updating mods info: getting online updates..";
            }
            List <IModInfo> mifInfo = new List <IModInfo>();

            IMod[] ModCheckList = p_lstModCheck.ToArray();

            try
            {
                //get mod info
                for (int i = 0; i <= m_intRetries; i++)
                {
                    mifInfo = ModRepository.GetFileListInfo(p_lstModList);

                    if (mifInfo != null)
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                }

                if (mifInfo != null)
                {
                    IModInfo[] mifModUpdates = mifInfo.ToArray();
                    ItemProgress        = 0;
                    ItemProgressMaximum = mifInfo.Count;

                    for (int i = 0; i < mifModUpdates.Count(); i++)
                    {
                        ModInfo modUpdate = (ModInfo)mifModUpdates[i];
                        if (m_booCancel)
                        {
                            break;
                        }
                        if (OverallProgress < OverallProgressMaximum)
                        {
                            StepOverallProgress();
                        }

                        if (modUpdate == null)
                        {
                            continue;
                        }

                        ItemMessage = modUpdate.ModName;

                        IMod modMod = null;
                        if (m_booMissingDownloadId != false)
                        {
                            modMod = m_lstModList.Where(x => x != null).Where(x => !string.IsNullOrEmpty(modUpdate.FileName) && (StripFileName(modUpdate.FileName, modUpdate.Id).Equals(StripFileName(Path.GetFileName(x.Filename).ToString(), x.Id), StringComparison.OrdinalIgnoreCase) || StripFileName(modUpdate.FileName, modUpdate.Id).Equals(StripFileName(Path.GetFileName(x.Filename.Replace("_", " ")).ToString(), x.Id), StringComparison.OrdinalIgnoreCase))).FirstOrDefault();
                        }
                        else
                        {
                            modMod = m_lstModList.Where(x => x != null).Where(x => !string.IsNullOrEmpty(modUpdate.FileName) && modUpdate.FileName.Equals(Path.GetFileName(x.Filename).ToString(), StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        }

                        if (modMod == null)
                        {
                            if ((!string.IsNullOrEmpty(modUpdate.DownloadId)) && (modUpdate.DownloadId != "0") && (modUpdate.DownloadId != "-1"))
                            {
                                modMod = m_lstModList.Where(x => x != null).Where(x => !string.IsNullOrEmpty(x.DownloadId) && modUpdate.DownloadId.Equals(x.DownloadId.ToString(), StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                            }
                        }

                        if (modMod == null)
                        {
                            if (m_booMissingDownloadId != false)
                            {
                                if (ModCheckList.Count() == mifModUpdates.Count())
                                {
                                    IMod modCheck = ModCheckList[i];
                                    if ((!string.IsNullOrEmpty(modUpdate.Id) && modUpdate.Id != "0") && (!string.IsNullOrEmpty(modCheck.Id) && modCheck.Id != "0"))
                                    {
                                        if (modUpdate.Id.Equals(modCheck.Id, StringComparison.OrdinalIgnoreCase))
                                        {
                                            modMod = modCheck;
                                        }
                                    }
                                }
                            }
                        }

                        if (modMod != null)
                        {
                            if (ItemProgress < ItemProgressMaximum)
                            {
                                StepItemProgress();
                            }

                            if (modUpdate.DownloadId == "-1")
                            {
                                if (m_booMissingDownloadId != false)
                                {
                                    string Filename = Path.GetFileName(modMod.Filename);
                                    if (!string.Equals(StripFileName(Filename, modMod.Id), StripFileName(modUpdate.FileName, modUpdate.Id), StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        continue;
                                    }
                                }
                            }
                            else if (!string.IsNullOrWhiteSpace(modUpdate.DownloadId) && !modUpdate.DownloadId.Equals(modMod.DownloadId))
                            {
                                if (m_booMissingDownloadId != false)
                                {
                                    string Filename = Path.GetFileName(modMod.Filename);
                                    if (string.Equals(Filename, modUpdate.FileName, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        if (!dctNewDownloadID.ContainsKey(Filename))
                                        {
                                            dctNewDownloadID.Add(Filename, modUpdate.DownloadId);
                                        }
                                    }
                                    else if (!string.IsNullOrEmpty(modMod.Id) && (modMod.Id != "0") && !string.IsNullOrEmpty(modUpdate.Id) && (modUpdate.Id != "0"))
                                    {
                                        if (string.Equals(modMod.Id, modUpdate.Id, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            if (!dctNewDownloadID.ContainsKey(Filename))
                                            {
                                                dctNewDownloadID.Add(Filename, modUpdate.DownloadId);
                                            }
                                        }
                                    }
                                }
                            }

                            if (!string.IsNullOrEmpty(modMod.DownloadId) && string.IsNullOrWhiteSpace(modUpdate.DownloadId))
                            {
                                modUpdate.DownloadId = modMod.DownloadId;
                            }

                            if (m_booMissingDownloadId != false)
                            {
                                modUpdate.HumanReadableVersion = !string.IsNullOrEmpty(modMod.HumanReadableVersion) ? modMod.HumanReadableVersion : modUpdate.HumanReadableVersion;
                                modUpdate.MachineVersion       = modMod.MachineVersion != null ? modMod.MachineVersion : modUpdate.MachineVersion;
                            }

                            if ((modMod.CustomCategoryId != 0) && (modMod.CustomCategoryId != -1))
                            {
                                modUpdate.CustomCategoryId = modMod.CustomCategoryId;
                            }

                            modUpdate.UpdateWarningEnabled = modMod.UpdateWarningEnabled;
                            AutoUpdater.AddNewVersionNumberForMod(modMod, modUpdate);

                            if (!OverrideLocalModNames)
                            {
                                modUpdate.ModName = modMod.ModName;
                            }

                            modMod.UpdateInfo(modUpdate, null);
                            ItemProgress = 0;
                        }
                    }
                }
            }
            catch (RepositoryUnavailableException e)
            {
                return("The check failed for a server-side issue:" + Environment.NewLine + Environment.NewLine + e.Message);
            }

            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="p_objArgs">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] p_objArgs)
        {
            int intModLimit = 75;

            if (m_booMissingDownloadId != false)
            {
                intModLimit = 75;
            }

            List <string>       ModList    = new List <string>();
            List <IMod>         ModCheck   = new List <IMod>();
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            OverallMessage          = "Updating mods info: setup search..";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgress            = 0;
            ItemProgressStepSize    = 1;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = 1;

            OverallProgressMaximum = m_lstModList.Count * 2;
            ItemProgressMaximum    = (m_lstModList.Count > intModLimit) ? intModLimit : m_lstModList.Count;

            for (int i = 0; i < m_lstModList.Count; i++)
            {
                IMod   modCurrent = m_lstModList[i];
                string modID      = string.Empty;
                string modName    = string.Empty;
                int    isEndorsed = 0;
                ItemMessage = modCurrent.ModName;

                if (m_booCancel)
                {
                    break;
                }

                modName = StripFileName(modCurrent.Filename, modCurrent.Id);

                if (!string.IsNullOrEmpty(modCurrent.Id))
                {
                    modID      = modCurrent.Id;
                    isEndorsed = modCurrent.IsEndorsed == true ? 1 : (modCurrent.IsEndorsed == false ? -1 : 0);
                }
                else
                {
                    try
                    {
                        IModInfo mifInfo = ModRepository.GetModInfoForFile(modCurrent.Filename);

                        if (mifInfo != null)
                        {
                            modCurrent.Id = mifInfo.Id;
                            modID         = mifInfo.Id;
                            AutoUpdater.AddNewVersionNumberForMod(modCurrent, mifInfo);
                            modName = StripFileName(modCurrent.Filename, mifInfo.Id);
                        }
                    }
                    catch (RepositoryUnavailableException)
                    {
                        //the repository is not available, so don't bother
                    }
                }

                if ((m_booMissingDownloadId == null) || ((m_booMissingDownloadId == true) && (string.IsNullOrEmpty(modCurrent.DownloadId) || (modCurrent.DownloadId == "0") || (modCurrent.DownloadId == "-1"))))
                {
                    ModList.Add(string.Format("{0}|{1}|{2}", modName, string.IsNullOrWhiteSpace(modID) ? "0" : modID, Path.GetFileName(modCurrent.Filename)));
                    ModCheck.Add(modCurrent);
                }
                else if ((m_booMissingDownloadId == false) && !string.IsNullOrEmpty(modCurrent.DownloadId))
                {
                    if (m_booOverrideCategorySetup)
                    {
                        ModList.Add(string.Format("{0}", modCurrent.DownloadId));
                    }
                    else
                    {
                        ModList.Add(string.Format("{0}|{1}|{2}|{3}|{4}", string.IsNullOrWhiteSpace(modCurrent.DownloadId) ? "0" : modCurrent.DownloadId, string.IsNullOrWhiteSpace(modID) ? "0" : modID, Path.GetFileName(modName), string.IsNullOrWhiteSpace(modCurrent.HumanReadableVersion) ? "0" : modCurrent.HumanReadableVersion, isEndorsed));
                    }
                    ModCheck.Add(modCurrent);
                }

                if (ItemProgress < ItemProgressMaximum)
                {
                    StepItemProgress();
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }

                // Prevents the repository request string from becoming too long.
                if (ModList.Count == intModLimit)
                {
                    string strResult = CheckForModListUpdate(ModList, ModCheck);

                    if (!string.IsNullOrEmpty(strResult))
                    {
                        ModList.Clear();
                        return(strResult);
                    }

                    ModList.Clear();
                    OverallMessage      = "Updating mods info: setup search..";
                    ItemProgress        = 0;
                    ItemProgressMaximum = (m_lstModList.Count == intModLimit) ? 1 : (m_lstModList.Count - (i + 1));
                }
            }

            if (!m_booCancel && (ModList.Count > 0))
            {
                string strResult = CheckForModListUpdate(ModList, ModCheck);

                if (!string.IsNullOrEmpty(strResult))
                {
                    m_lstModList.Clear();
                    return(strResult);
                }
            }

            m_lstModList.Clear();

            return(dctNewDownloadID);
        }
        /// <summary>
        /// Checks for the updated information for the given mods.
        /// </summary>
        /// <param name="modList">The mods for which to check for updates.</param>
        private string CheckForModListUpdate(List <string> modList, List <IMod> modsToCheck)
        {
            OverallMessage = _missingDownloadId != false ? "Updating mods info: retrieving download ids.." : "Updating mods info: getting online updates..";
            var fileListInfo = new List <IModInfo>();
            var modCheckList = modsToCheck.ToArray();

            //get mod info
            for (var i = 0; i <= _retries; i++)
            {
                fileListInfo = ModRepository.GetFileListInfo(modList);

                if (fileListInfo != null)
                {
                    break;
                }

                Thread.Sleep(1000);
            }

            if (fileListInfo != null)
            {
                var modUpdates = fileListInfo.ToArray();
                ItemProgress        = 0;
                ItemProgressMaximum = fileListInfo.Count;

                for (var i = 0; i < modUpdates.Count(); i++)
                {
                    var modUpdate = (ModInfo)modUpdates[i];
                    if (_cancel)
                    {
                        break;
                    }

                    if (OverallProgress < OverallProgressMaximum)
                    {
                        StepOverallProgress();
                    }

                    if (modUpdate == null)
                    {
                        continue;
                    }

                    ItemMessage = modUpdate.ModName;

                    var mod = _missingDownloadId != false?_modList.Where(x => x != null).FirstOrDefault(x => !string.IsNullOrEmpty(modUpdate.FileName) && (StripFileName(modUpdate.FileName, modUpdate.Id).Equals(StripFileName(Path.GetFileName(x.Filename).ToString(), x.Id), StringComparison.OrdinalIgnoreCase) || StripFileName(modUpdate.FileName, modUpdate.Id).Equals(StripFileName(Path.GetFileName(x.Filename.Replace("_", " ")).ToString(), x.Id), StringComparison.OrdinalIgnoreCase))) : _modList.Where(x => x != null).FirstOrDefault(x => !string.IsNullOrEmpty(modUpdate.FileName) && modUpdate.FileName.Equals(Path.GetFileName(x.Filename)?.ToString(), StringComparison.OrdinalIgnoreCase));

                    if (mod == null && !string.IsNullOrEmpty(modUpdate.DownloadId) && modUpdate.DownloadId != "0" && modUpdate.DownloadId != "-1")
                    {
                        mod = _modList.Where(x => x != null).FirstOrDefault(x => !string.IsNullOrEmpty(x.DownloadId) && modUpdate.DownloadId.Equals(x.DownloadId.ToString(), StringComparison.OrdinalIgnoreCase));
                    }

                    if (mod == null)
                    {
                        if (_missingDownloadId != false)
                        {
                            if (modCheckList.Count() == modUpdates.Count())
                            {
                                var modCheck = modCheckList[i];
                                if (!string.IsNullOrEmpty(modUpdate.Id) && modUpdate.Id != "0" && !string.IsNullOrEmpty(modCheck.Id) && modCheck.Id != "0")
                                {
                                    if (modUpdate.Id.Equals(modCheck.Id, StringComparison.OrdinalIgnoreCase))
                                    {
                                        mod = modCheck;
                                    }
                                }
                            }
                        }
                    }

                    if (mod != null)
                    {
                        if (ItemProgress < ItemProgressMaximum)
                        {
                            StepItemProgress();
                        }

                        if (modUpdate.DownloadId == "-1")
                        {
                            if (_missingDownloadId != false)
                            {
                                var filename = Path.GetFileName(mod.Filename);

                                if (!string.Equals(StripFileName(filename, mod.Id), StripFileName(modUpdate.FileName, modUpdate.Id), StringComparison.InvariantCultureIgnoreCase))
                                {
                                    continue;
                                }
                            }
                        }
                        else if (!string.IsNullOrWhiteSpace(modUpdate.DownloadId) && !modUpdate.DownloadId.Equals(mod.DownloadId))
                        {
                            if (_missingDownloadId != false)
                            {
                                var filename = Path.GetFileName(mod.Filename);

                                if (string.Equals(filename, modUpdate.FileName, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    if (!_newDownloadID.ContainsKey(filename))
                                    {
                                        _newDownloadID.Add(filename, modUpdate.DownloadId);
                                    }
                                }
                                else if (!string.IsNullOrEmpty(mod.Id) && mod.Id != "0" && !string.IsNullOrEmpty(modUpdate.Id) && modUpdate.Id != "0")
                                {
                                    if (string.Equals(mod.Id, modUpdate.Id, StringComparison.InvariantCultureIgnoreCase) && !_newDownloadID.ContainsKey(filename))
                                    {
                                        _newDownloadID.Add(filename, modUpdate.DownloadId);
                                    }
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(mod.DownloadId) && string.IsNullOrWhiteSpace(modUpdate.DownloadId))
                        {
                            modUpdate.DownloadId = mod.DownloadId;
                        }

                        if (_missingDownloadId != false)
                        {
                            modUpdate.HumanReadableVersion = !string.IsNullOrEmpty(mod.HumanReadableVersion) ? mod.HumanReadableVersion : modUpdate.HumanReadableVersion;
                            modUpdate.MachineVersion       = mod.MachineVersion != null ? mod.MachineVersion : modUpdate.MachineVersion;
                        }

                        if (mod.CustomCategoryId != 0 && mod.CustomCategoryId != -1)
                        {
                            modUpdate.CustomCategoryId = mod.CustomCategoryId;
                        }

                        modUpdate.UpdateWarningEnabled = mod.UpdateWarningEnabled;
                        modUpdate.UpdateChecksEnabled  = mod.UpdateChecksEnabled;
                        AutoUpdater.AddNewVersionNumberForMod(mod, modUpdate);

                        if (!_overrideLocalModNames)
                        {
                            modUpdate.ModName = mod.ModName;
                        }

                        if (!string.IsNullOrEmpty(mod.ModName))
                        {
                            modUpdate.ModName = string.Empty;
                        }
                        mod.UpdateInfo(modUpdate, null);
                        ItemProgress = 0;
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// The method that is called to start the background task.
        /// </summary>
        /// <param name="args">Arguments to for the task execution.</param>
        /// <returns>Always null.</returns>
        protected override object DoWork(object[] args)
        {
            const int modLimit = 75;

            List <string> updatedMods = new List <string>();

            var modList  = new List <string>();
            var modCheck = new List <IMod>();

            OverallMessage          = "Updating mods info: setup search..";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgress            = 0;
            ItemProgressStepSize    = 1;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = 1;

            OverallProgressMaximum = _modList.Count * 2;
            ItemProgressMaximum    = _modList.Count > modLimit ? modLimit : _modList.Count;

            if (!string.IsNullOrEmpty(_period))
            {
                // get mod updates
                updatedMods = ModRepository.GetUpdated(_period);
            }

            for (var i = 0; i < _modList.Count; i++)
            {
                if (_cancel)
                {
                    break;
                }

                var modCurrent = _modList[i];
                var modId      = string.Empty;
                var isEndorsed = 0;
                ItemMessage = modCurrent.ModName;

                var modName = StripFileName(modCurrent.Filename, modCurrent.Id);

                if (!string.IsNullOrEmpty(modCurrent.Id))
                {
                    modId      = modCurrent.Id;
                    isEndorsed = modCurrent.IsEndorsed == true ? 1 : modCurrent.IsEndorsed == false ? -1 : 0;
                }
                else
                {
                    var modInfoForFile = ModRepository.GetModInfoForFile(modCurrent.Filename);

                    if (modInfoForFile != null)
                    {
                        modCurrent.Id = modInfoForFile.Id;
                        modId         = modInfoForFile.Id;
                        AutoUpdater.AddNewVersionNumberForMod(modCurrent, modInfoForFile);
                        modName = StripFileName(modCurrent.Filename, modInfoForFile.Id);
                    }
                }

                if (_missingDownloadId == null || _missingDownloadId == true && (string.IsNullOrEmpty(modCurrent.DownloadId) || modCurrent.DownloadId == "0" || modCurrent.DownloadId == "-1"))
                {
                    if (updatedMods.Count > 0 && !string.IsNullOrWhiteSpace(modId) && updatedMods.Contains(modId, StringComparer.OrdinalIgnoreCase))
                    {
                        modList.Add(string.Format("{0}|{1}|{2}", modName, modId, Path.GetFileName(modCurrent.Filename)));
                        modCheck.Add(modCurrent);
                    }
                    else if (updatedMods.Count == 0 || string.IsNullOrWhiteSpace(modId))
                    {
                        modList.Add(string.Format("{0}|{1}|{2}", modName, string.IsNullOrWhiteSpace(modId) ? "0" : modId, Path.GetFileName(modCurrent.Filename)));
                        modCheck.Add(modCurrent);
                    }
                }
                else if (_missingDownloadId == false && !string.IsNullOrEmpty(modCurrent.DownloadId))
                {
                    if (_overrideCategorySetup)
                    {
                        modList.Add(string.Format("{0}", modCurrent.DownloadId));
                    }
                    else
                    {
                        modList.Add(string.Format("{0}|{1}|{2}|{3}|{4}", string.IsNullOrWhiteSpace(modCurrent.DownloadId) ? "0" : modCurrent.DownloadId, string.IsNullOrWhiteSpace(modId) ? "0" : modId, Path.GetFileName(modName), string.IsNullOrWhiteSpace(modCurrent.HumanReadableVersion) ? "0" : modCurrent.HumanReadableVersion, isEndorsed));
                    }
                    modCheck.Add(modCurrent);
                }

                if (ItemProgress < ItemProgressMaximum)
                {
                    StepItemProgress();
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (_cancel)
                {
                    break;
                }

                // Prevents the repository request string from becoming too long.
                if (modList.Count == modLimit)
                {
                    string strResult = CheckForModListUpdate(modList, modCheck);

                    if (!string.IsNullOrEmpty(strResult))
                    {
                        modList.Clear();
                        return(strResult);
                    }

                    modList.Clear();
                    OverallMessage      = "Updating mods info: setup search..";
                    ItemProgress        = 0;
                    ItemProgressMaximum = _modList.Count == modLimit ? 1 : _modList.Count - (i + 1);
                }
            }

            if (!_cancel && modList.Count > 0)
            {
                string strResult = CheckForModListUpdate(modList, modCheck);

                if (!string.IsNullOrEmpty(strResult))
                {
                    _modList.Clear();
                    return(strResult);
                }
            }

            _modList.Clear();

            return(_newDownloadID);
        }